How to disable Events for a while in Javascript or jQuery
Posted
by Tarik
on Stack Overflow
See other posts from Stack Overflow
or by Tarik
Published on 2010-04-06T06:07:45Z
Indexed on
2010/04/06
6:13 UTC
Read the original article
Hit count: 495
Hello,
I am wondering if you guys know different approach to disable an event for a while. Let me elaborate this more :
Lets say I have a div or button which has a subscriber to its onclick
event. To prevent the double click when the the methods are doing some ajax things, these are the some of the ways we can do :
- Disable the button till the method finishes its job
- Unbind till the methods finishes its job and then bind it again.
- Use some kind of flagging system like boolean so it will prevent method from working more than once.
So is there any other ways, maybe some javascript tricks or jQuery tricks which is more efficient and better practice.
Thanks in advance.
© Stack Overflow or respective owner