638 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.

638 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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by