ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Javascript Toggles

January 22, 2013 10:14am

Subscribe [1]
  • #1 / Jan 22, 2013 10:14am

    j00lz

    4 posts

    Hi,

    I’m using a template that has some javascript hide/show toggles which I’ve setup to show my categories like so:

    <div class="toggle-trigger" id="toggle-trigger-{cat_id}"> title etc….. </div>
    <div class="toggle-container" id="toggle-container-{cat_id}"> individual categories listed with links etc. </div>

    The javascript is working fine but I’d like to get the page to ‘click’ and open the relevant category.

    I added the ID’s as seen above to help with this and I can see they are all working fine.

    I’m scratching my head with the javascript though, and think it’s an issue with parsing, ie. where it should be…. I’ve tried a bunch of things and non seem to work… anyway here is my code:

    {if {last_segment_category_parent_id} == cat_id }
     [removed]
      alert("Here we go!");
      $('#toggle-container-{cat_id}').toggle('slow');
      $('#toggle-container-{cat_id}').show();
      $('#toggle-trigger-{cat_id}').toggle('slow');
      $('#toggle-container-{cat_id}').toggleClass("active");
      $('#toggle-trigger-{cat_id}').click();
      $("#toggle-trigger-{cat_id}").trigger("click");
     [removed]
     script should have run!
    {/if}

    All those different lines are an attempt to get the damn toggle open! The alert is opening fine but nothing happens to my containers no matter what I do….

    I’m really not very experienced in javascript so don’t really know how to approach this properly.

    Any help with this would be much appreciated.

    Thanks in advance,

    j00lz

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases