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 }); }
2.1m questions
2.1m answers
60 comments
57.0k users