jquery - unbind click, but keep eventPreventDefault(); -


i'm trying unbind click on animation until animation finishes keep overlapping animiations happening. unbind works fine, of course, event.preventdefault stops working , button/link becomes active again. i'm not sure how work way around this.

shortened version of code is:

$('a.next').bind('click', slidefwd); function slidefwd(e){     e.preventdefault();     $('a.next').unbind();     $('ul.gridviewlist').animate({         left: '-=800px'         }, 'slow', function() {         $('a.next').bind('click', slidefwd);         }); }; 

and html is:

<div>      <div class="slidecontrol">         <p class="pages"><span class="prodcountdisplay">#</span> of <span class="prodcounttotal">10</span></p>         <ul>             <li><a class="disabled button_back previous" href="#">prev</a></li>             <li><a class="button_next next" href="#">next</a></li>         </ul>     </div>     <ul class="gridviewlist">         <li class="prodwrap">this slider space 1</li>         <li class="prodwrap"> slider space 2</li>         <li class="prodwrap"> slider space 3</li>         <li class="prodwrap"> slider space 4</li>         <li class="prodwrap"> slider space 5 </li>         <li class="prodwrap">this slider space 6 </li>         <li class="prodwrap"> slider space 7</li>         <li class="prodwrap"> slider space 8 </li>         <li class="prodwrap"> slider space 9 </li>         <li class="prodwrap"> slider space 10 </li>     </ul> <!-- ul.gridviewlist --> </div>  

a complete working version here: http://iwrb.idleprattle.com/slider.htm (only next has unbind/bind set now)

i tried taking preventdefault outside function slidefwd, must unbind too. i.e.

$('a.next').click(function(){e.preventdefault();}); 

you this:

$('a.next').bind('click', slidefwd);  ...  $('a.next').unbind().bind('click',function(e){e.preventdefault();});  ...  $('a.next').unbind().bind('click', slidefwd); 

Comments