ISSUE:
jQuery sending out multiple of the same ajax calls when you really only wanted one.
FIX:
$('.myButton').unbind().bind('click', myMethod);
Sometimes, less is more in this world and that’s how I like my ajax.
When creating an application or website that is using ajax most of the time you will be attaching an event to an element in the DOM. Or in plain english attaching an onClick event to a link or button.
If you are dynamically creating html, you may need to use the jquery .bind() method.
But if you don’t pay real close attention and recreate the same element using the same code, it will bind again.
So when you only press your button once, it is firing multiple clicks events because you used bind multiple times on the same element.
How do we stop this you ask?
Using the jquery .unbind() method before .bind() will unbind the already bound events to reset your element.
Learn the foundation of the DHTMLX Suite quickly while building a single page application with multiple components in harmony.
How often do you work with tables? I work with them quite a bit and styling t read more...
UPDATE!! A plugin is now available for this tutorial that includes more features read more...
When running a site with a boat load of javascript, you may want to run a script read more...
There seems to be a lot of misconceptions on the difference between the document read more...
Greetings All! Since everyone was digging the Star Comment Rating I decided that read more...
FINALLY found a solution to the issue I was having. I was using .change() to dynamically bind a function to a select box, and I guess binding it multiple times makes it fire multiple times. This solved my issue. Thanks!!
Fixed an issue I was having with multiple comments posting. Thanks
nice solution.
Finally!!! After days and days of multiple sessions, I found this.
Really nice! Not works using $(‘.myButton’).unbind().bind(‘click’, myMethod) but I solved my issue adding $(‘#foo’).unbind(‘click’); in .done(function(data) event attached with $.ajax. Thank You!
Thank you!