Peps,

Look into the LiveQuery plugin.  It monitors the DOM, and automatically 
binds events to new elements created from ajax requests.  There are 
other methods to do this is well.  Check out this jQuery FAQ:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_request.3F

HTH,
Carl

Peps wrote:
> Hi,
>
> I have finished developping a website with jQuery. First of all,
> thanks to everybody who worked on this great Javascript library. It's
> truly an incredible timesaver.
>
> My question concerns binding and unbinding events when there are Ajax
> calls in which content is injected into the DOM. At first I noticed
> that the newly injected elements where not affected by the original
> event bindings. I realized I had to rebind everything on each Ajax
> calls. However that was not the end of my problems. I noticed that
> when you rebind everything, all the elements which were not injected
> in the DOM through the Ajax calls were actually binded double!
>
> My final strategy has been to unbind everything on each ajax calls and
> THEN rebind every event (a 12kb JS file) within the file which was
> called through the ajax request. This works on all browser and the
> speed is good. I know however that this is probably not the best way
> to go...
>
> Does anyone have any advice which they could give me?
>
> Thank you.
>
>
>   

Reply via email to