Hi Michael,

You have run into a fairly common issue: how to get events to work with elements that are added to the DOM, through either ajax or simple DOM mainpulation, after the "document ready" code has already fired.

This FAQ topic should answer your question:

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

If you still have problems after reading through it and trying one of the many solutions, let us know.

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Aug 18, 2008, at 7:43 AM, Michael Anckaert wrote:


Hello everyone,

I'm trying to do something that's probably trivial, but I can't get it
to work :p

My main page has a div where content gets loaded via ajax:

$('#main').load('page.html');

The file page.html has some html and javascript code, the problem is
getting the javascript from page.html executed. I tried using a
callback like this (found here on this list):

                $('#main').load('page.html',
                                {},
                                function() {
                                        $("#main 
script").each(function(ind,obj){eval($(obj).text());});
                                });

but no success so far.
Can anyone point me in the right direction?

Reply via email to