I am trying to remove an event listener from a specific DOM element and have problems. Below are the parts of the code I'm playing with:
Search.Views.MainSearch = Backbone.View.extend({
events: {
'click #search-submit' : 'searchSubmit',
'click #some-button': 'disableSearch',
'click #some-other-button': 'someFunction'
}|,
disableSearch: function(){
$(this.el).off('click');
}
Clicking the # search-submit button works as expected. Clicking the # some-button button works because it calls the disableSearch method. However, I cannot remove only the click event from the # search-submit button. I can remove all listeners, but this is not suitable for my purpose, because it removes the listener from # some-other-button.
Is there a way to remove only event listeners that excite me and leave them intact? Is there a better way to hook event listeners first? Thanks...