Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery unbind/disable navigation link
    primarykey
    data
    text
    <p>Hy,</p> <p>a really stupid problem, but i cant get it to work:</p> <p>I have some function that binds the click of my navigation. When a link is clicker it gets the class "active". So my idea was that i just say:</p> <pre><code>&lt;a id="link1" class="main"&gt;link1&lt;/a&gt; &lt;a id="link2" class="main"&gt;link2&lt;/a&gt; &lt;a id="link3" class="main"&gt;link3&lt;/a&gt; $('a.main').bind('click', function(){ $(this).removeClass('active'); //some code $(this).addClass('active'); } </code></pre> <p>So far thats working. My element gets the active class when it´s hit and removes when another has been clicked. My idea now was just simple unbind all active links (otherwise some double reloading happends by paranoid 10000 clicks on my navigation =)</p> <pre><code>§('a.active').unbind('click'); </code></pre> <p>I also specify for each element in my navigation a special event:</p> <pre><code>$('a#link1').bind('click', function() { $img.fadeOut('slow', function() { $('#bg div table tr td').addClass('loading'); $img.attr('src', 'images/image.jpg'); }); }); </code></pre> <p>Now what happends is, that if i click an element in my navigation (accordion), the thing slides down, gets the active class (still keeps the main class):</p> <pre><code>&lt;a id="link1" class="main active"&gt;link1&lt;/a&gt; </code></pre> <p>When i click another element in the navigation, this one closes and the active class is removed.</p> <p>BUT when i go back to that link before, it´s nnot clickable anymore? So, i guess jQuery unbinds the click event for ever from an element that has been active. Sounds a bit stupid and unlogic to me...</p> <p>Maybe is there a way to enable/disabel these. So a function that checks if the element has an active class it should be disabled. Or is the problem the "main" class beside the "active" class...</p> <p>Any idea?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload