I'm having a problem. Basically, when a user clicks an 'Edit' link on a page, the following Jquery code runs:
$("#saveBtn").click(function () {
saveQuestion(id);
});
By doing this, the onClick event of the save button calls the saveQuestion()
method and passes on the ID of the question for which the 'Edit' link was clicked.
But if in the same session the user clicks edit on 2 questions, then instead of overwriting the previous click
event handler, it instead causes 2 event handlers to run, one which might call saveQuestion(1)
and the other might call saveQuestion(2)
. By doing this 1 question overwrites the other.
Is there a way to remove all previous click
events that have been assigned to a button?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…