Reputation: 63717
I want to temporarily ignore any click events on a button #firstBtn
for 5 seconsd after it has been clicked on.
Template.sidebar.events({
'click #firstBtn': function () {
//...
}
})
How can this be done? Looked into
$('#firstBtn').unbind('click', eventHandler)
Meteor.setTimeout(function(){
$('#firstBtn').bind('click', eventHandler)
}, 5000)
but how should we refer to the click event handler in template sidebar
?
Upvotes: 0
Views: 116
Reputation: 1002
Try something like this:
First, initialize a variable to set the timeout, and a variable to say if the button has been clicked. This is needed for the conditional statement.
var timeout = 5000; //5000 milliseconds is equal to 5 seconds
var isClickable = true;
Then, Try some conditional testing like this:
$('#firstBtn').click(function(){
if(isClickable){
...
//standard link handling code
...
isClickable = false;
setTimeout(function(){isClickable = true;},timeout)
}else{
return;
}
});
This will only allow the click event's handling code to execute if the timeout is comeplete.
Upvotes: 1