aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes window.setInterval messing up jQuery button handler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "window.setInterval messing up jQuery button handler" Watch "window.setInterval messing up jQuery button handler" New topic
Author

window.setInterval messing up jQuery button handler

K Mansoor
Ranch Hand

Joined: Jan 10, 2006
Posts: 52
Hello- I am facing a weired behavior; JQuery is firing button handler multiple times when window.setiInterval is also used on the same page.

Details:

I have an HTML table refreshed every 5 seconds:


The container div's above are rendered by two separate JSP's. The table rendered has a button for each row and if clicked it is supposed to submit an ajaxForm, the following is from the JSP:



The problem is this: ajaxForm is submitted 8 times, instead of one, and when the next window.interval timer is fired the ajax load also initiated 8 times. I'm using Firebug. It shows multiple ajax calls. If I remove window.setInterval everything works fine. The number of calls keep getting increased, so the next time it is 14 or 16.

Has anyone seen this kind of behavior? I'll appreciate any help.
Thanks.


Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
because you are using live. Live listens for new elements added to the page. So everytime you call this you add another live() call. So you get multiple clicks.

Eric
K Mansoor
Ranch Hand

Joined: Jan 10, 2006
Posts: 52
That was it. I wasted a lot of time on it, really appreciate your help.
Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: window.setInterval messing up jQuery button handler
 
Similar Threads
Is there something better then event.pageX/Y?
Jquery Event Sequence
jQuery AJAX display issue
JQuery.UI Dialog & $().load() & JavaScript
My form submit is called twice