Say I have something like the following to trap the click event of a button:
$(\"#button_id\").click(function() {
//disable click event
//do something
Try utilizing .one()
var button = $("#button"),
result = $("#result"),
buttonHandler = function buttonHandler(e) {
result.html("processing...");
$(this).fadeOut(1000, function() {
// do stuff
setTimeout(function() {
// reset `click` event at `button`
button.fadeIn({
duration: 500,
start: function() {
result.html("done at " + $.now());
}
}).one("click", buttonHandler);
}, 5000)
})
};
button.one("click", buttonHandler);
#button {
width: 50px;
height: 50px;
background: olive;
}