I follow this topic to disable / enable click on a button.
Best way to remove an event handler in jQuery?
his idea is that you can also use the live () method to enable / disable events. What happens with this code is that when you click on a tag element, such as .load-item, it will add a class that is disabled for this element. This will cause the selector to no longer match the element, and the event will not be fired until the "disabled" class is deleted, again making the .live () selector valid.
Below is what I went out with and it disables the pressing of the first button,
$('.load-item:not(.disabled)').live('click',function(){
$(this).parentsUntil('.column-global').addClass('current');
$('.current a').each(function(index) {
$(this).addClass('disabled');
});
....
});
and I have another function to remove a disabled class when you click on another button,
$('.button-return').click(function(){
...
$('.current a').each(function(index) {
$(this).removeClass('disabled');
});
...
$('.item-global').removeClass('current');
return false;
});
, , , .
- - live() ? , live() , ?
.