Say I have something like the following to trap the click event of a button:
$(\"#button_id\").click(function() {
//disable click event
//do something
This is a more idiomatic alternative to the artificial state variable solutions:
$("#button_id").one('click', DoSomething);
function DoSomething() {
// do something.
$("#button_id").one('click', DoSomething);
}
One will only execute once (until attached again). More info here: http://docs.jquery.com/Events/one