Contents
How to fix jQuery Ajax click event firing multiple times?
1) Move your javascript code into main.asp, instead of modal.asp. This will instantly fix your double-fire issue. You would have to modify your code slightly to pull the WatchListID value from some HTML inside modal.asp, rather than coding it directly as you are (since main.asp won’t have that value yet.)
Can a jQuery event handler be called more than once?
JQuery one ensures that your event handler only called once. Additionally, you can subscribe your event handler with one to allow further clicks when you have finished the processing of the current click operation. …
How to stop live events in jQuery Ajax?
You would have to modify your code slightly to pull the WatchListID value from some HTML inside modal.asp, rather than coding it directly as you are (since main.asp won’t have that value yet.) 2) Keep your javascript code where it is, but stop using live events. Use a simple “.click (function () {” call, instead of “.live (‘click’, function () {“.
How to bind Ajax event only once in jQuery?
Alternatively you can use the context property on your ajax request, check the documentation. As I see, all you want to do is bind the event once and then die it. The latest jQuery versions have a .one () method, which will bind the event only once.
Why does jQuery click function not work after Ajax call?
Same code as yours but it will work on dynamically created elements. The click event doesn’t exist at that point where the event is defined. You can use live or delegate the event. I tested a simple solution that works for me!
How to bind Ajax click event in jQuery?
Also make sure you save the this object in a variable, as it’s not pointing to your DOM element within the ajax callback function. Alternatively you can use the context property on your ajax request, check the documentation. As I see, all you want to do is bind the event once and then die it.
Why is click event not working in jQuery?
If you use AJAX on your website, beware that events like click, submit, hover might not work if you don’t attach them properly. I will be using click event to describe the problem, but all of this applies to most events in jQuery. Let say I have an item with a title and hidden description.