I have the following code:
function someMethod() { $(obj).click(function {}); }
someMethod is called twice and thus click event is binded twice. How can I make it bind only once?
If you can apply it, probably want to take a look at event.preventDefault and event.stopPropagation OR unbind and bind each time, within your method like
function someMethod() { $(obj).off('click').on('click', function(e) { // put your logic in here }); }
1.4m articles
1.4m replys
5 comments
57.0k users