630 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
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
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Located in Brazil
+2 more
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
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
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