Jump to content

Recommended Posts

well i am not a javascript expert or coder i need help to update this javascript so that it works properly with no errors

<script type="text/javascript">
<!--
$('.categoryNodeInfo').prepend("<div class='showhideNodes hideNodes'>Collapse</div>");
var showhideNodesCookie = $.getCookie('showhideNodes');
 var showhideNodesArray=new Array();
if (showhideNodesCookie) {
 showhideNodesArray = showhideNodesCookie.split(",");
 $.each(showhideNodesArray,function(){
        var selector = 'li[id='+this+']';
        $(selector+' ol.nodeList').hide();
        $(selector+' .showhideNodes').toggleClass('showNodes');
        $(selector+' .showhideNodes').toggleClass('hideNodes');
        $(selector+' .showhideNodes').text('showhideNodes_expand');
 });
}
$('.showhideNodes').click(
function() {
if ($(this).text() == 'Collapse') {
	$(this).parent().next().slideUp();
	$(this).text('showhideNodes_expand');
	//if($.inArray(this,showhideNodesArray) != -1){
		showhideNodesArray.push($(this).parent().parent().attr('id'));
		$.setCookie('showhideNodes',showhideNodesArray.join(","));
	//}
}
else if ($(this).text() == 'showhideNodes_expand') {
	$(this).parent().next().slideDown(); 
	$(this).text('Collapse');
        var remove = $(this).parent().parent().attr('id');
        showhideNodesArray.splice($.inArray(remove,showhideNodesArray),1);
        $.setCookie('showhideNodes',showhideNodesArray.join(","));
}
$(this).toggleClass('showNodes');
$(this).toggleClass('hideNodes');
});
//-->
</script>

well i hope someone can update it with its same functioning thanks and sorry for my bad english

Link to comment
https://forums.phpfreaks.com/topic/298736-javiscript-help/
Share on other sites

It is no good just dumping the code. How are supposed to help if do not explain what it is you are trying to do?

my mistake i am sorry ! sorry i didnt't explaind much

 

this code let node/categories of xenforo to collapse and expand but on reload of page they didn't remain collapsed. its collapse and expand function is working but cookie function is not working so i need help ;) for this code to work

 

i can make a live setup if anyone is interested in testing,

 

For Reference : https://xenforo.com/community/threads/dont-work-after-reload-script-js.77211/

Edited by loop0007
Link to comment
https://forums.phpfreaks.com/topic/298736-javiscript-help/#findComment-1523988
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.