File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

window.setInterval messing up jQuery button handler

 
K Mansoor
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was it. I wasted a lot of time on it, really appreciate your help.
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic