630 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Sold between 100 and 1 000 dollars
  • United Kingdom
RobbyDesigns says

I want my Toggle section to start in an open state.

Here’s the js it uses; I’ve tried editing it but it still loads the page with the ‘Drawers’ closed:

jQuery.noConflict(); jQuery(function() {

jQuery('.box-sidebar').each( function() {
    var widget_ID = jQuery(this).attr('id');
    if (jQuery.cookie(widget_ID) == 'open') {
        jQuery(this).find('.totoggle').show();
        jQuery(this).find('h3').addClass("toggle-close");
    } else {
        jQuery(this).find('.totoggle').hide();
        jQuery(this).find('h3').addClass("toggle-open");
    }
});
jQuery(".box-sidebar h3).click(function(){
if (jQuery(this).next('div.totoggle').is(")) {
       jQuery(this).next('div.totoggle').slideDown("slow");
       jQuery(this).removeClass("toggle-open");
       jQuery(this).addClass("toggle-close");
       jQuery.cookie(jQuery(this).parent().parent().attr('id'), 'open',{ path: '/' });
       return false;
   } else {
       jQuery(this).next('div.totoggle').slideUp("slow");
       jQuery(this).removeClass("toggle-close");
       jQuery(this).addClass("toggle-open");
       jQuery.cookie(jQuery(this).parent().parent().attr('id'), 'closed',{ path: '/' });
       return false;
   }
});

})

Please help.

147 posts
  • Bought between 1 and 9 items
  • Brazil
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
zecchin says
from what i see i believe that the :

jQuery('.box-sidebar').each( function() {
    var widget_ID = jQuery(this).attr('id');
    if (jQuery.cookie(widget_ID) == 'open') {
        jQuery(this).find('.totoggle').show();
        jQuery(this).find('h3').addClass("toggle-close");
    } else {
        jQuery(this).find('.totoggle').hide();
        jQuery(this).find('h3').addClass("toggle-open");
    }
});

this checks to see if it was previous opened or closed, i would change that so as to make them open by default.
I’m sorry for the leck of help, but i can’t help much without seeing this code in action, if you would show a preview of what you mean i could help more.

But form what i could understand the first if is the problem here, since it checks for a cookie, you should take that out, and leaving only this :

jQuery(this).find('.totoggle').show();
jQuery(this).find('h3').addClass("toggle-close");

well, this is pretty much a guess, hope it helped you with something.

630 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Sold between 100 and 1 000 dollars
  • United Kingdom
RobbyDesigns says

Thanks Eos; I’ve decided to not bother with the ‘Drawers’ idea because it was too gimmicky and too heavy (almost 100kb) by the time the page loaded all the js and css files for the drawers.

Appreciate your help; I have a fair idea of how to solve it if I ever use this idea in the future – thank you.

by
by
by
by
by
by