I have some code in jquery which looks like this:
$("#filterZaal").attr("disabled", "disabled");
$("#filterGenre").attr("disabled", "disabled");
$("#filterZaal").live("change", interceptZaalFilter);
$("#filterDag").live("change", interceptDagFilter);
$("#filterGenre").live("change", interceptGenreFilter);
Now, i have added a button, and when i push this button i would like that all of the above code does not count anymore, so when i push the button, these events would no longer be called but when i push it again it should become enabled again.
How can i do this in jquery?
Rather than add/remove the events each time with
die(), I’d just create a toggle flag:This seems to better capture what you want, and will almost certainly be more efficient.