javascript - How to remove all Click event handlers in Jquery -
I am having a problem Basically, when a user clicks on an 'edit' link on a page , Then runs the following Jquery code:
$ ("# saveBtn"). Click (function () {saveQuestion (id);}); By doing so, the onclick event of the save button calls the saveQuestion () method and goes to the ID of the question for which 'edit' The link was clicked on.
But if the user edits on 2 questions in the same session, instead of overwriting the last click event handler, instead of running 2 event handlers, Which can call Save Questian (1) and call another to saveQuestion (2) . This 1 question is overwritten from the other.
Did all previous click events be assigned to a button?
You will use this to remove an event:
$ ("# SaveBtn"). Off ("click on"); But this will force the all click event to this element if the task with SaveQuestion is only one instance, then the above must be done. If it is not done:
$ ("# saveBtn") closed ("click"). Click (function () {saveQuestion (id);});
Comments
Post a Comment