1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Don't work after reload (script js)

Discussion in 'XenForo Development Discussions' started by Allan, Jun 28, 2014.

  1. Allan

    Allan Well-Known Member

    Hey, i test this script:

    $('.categoryNodeInfo').prepend("<div class='showhideNodes hideNodes'>{xen:phrase showhideNodes_collapse}</div>");
    var showhideNodesCookie = $.getCookie('showhideNodes');
    var showhideNodesArray=new Array();
    if (showhideNodesCookie) {
    showhideNodesArray = showhideNodesCookie.split(",");
            var selector = 'li[id='+this+']';
            $(selector+' ol.nodeList').hide();
            $(selector+' .showhideNodes').toggleClass('showNodes');
            $(selector+' .showhideNodes').toggleClass('hideNodes');
            $(selector+' .showhideNodes').text('{xen:phrase showhideNodes_expand}');
    function() {
    if ($(this).text() == '{xen:phrase showhideNodes_collapse}') {
        $(this).text('{xen:phrase showhideNodes_expand}');
        //if($.inArray(this,showhideNodesArray) != -1){
    else if ($(this).text() == '{xen:phrase showhideNodes_expand}') {
        $(this).text('{xen:phrase showhideNodes_collapse}');
            var remove = $(this).parent().parent().attr('id');
    It works once and after reloading the page doesn't work.

    I have this error in console:


    What about you?
  2. Chris D

    Chris D XenForo Developer Staff Member

    This line is wrong:

    var selector = 'li[id='+this+']';
    The correct way to specfy an element with an ID would be:

    var selector = 'li#' + this;
    Allan likes this.
  3. Allan

    Allan Well-Known Member

    The reload work now ! Thank you Chris :)

    But don't keeps the user preferences (cookies) :(
  4. Allan

    Allan Well-Known Member

    Why cookies don't work ?
  5. Chris D

    Chris D XenForo Developer Staff Member

    No idea. You'll maybe need to be specific. Are they not setting? Not getting? Some other issue?
  6. Allan

    Allan Well-Known Member

    Difficult to explain, here is a screen of the console errors:

  7. Chris D

    Chris D XenForo Developer Staff Member

    Do you think it might be something to do with the line that says:

  8. Allan

    Allan Well-Known Member

    I corrected this error now, but the problem is still present, the cookies don't work.
  9. Allan

    Allan Well-Known Member

    I wonder if it does not lack a parameter "expire" ?

Share This Page