Button stops working after loading div via ajax
Posted
by
asovgir
on Stack Overflow
See other posts from Stack Overflow
or by asovgir
Published on 2012-11-07T04:44:43Z
Indexed on
2012/11/07
5:00 UTC
Read the original article
Hit count: 109
I have two divs on the page: main div and secondary, which loads a separate html page using ajax. All the links within the main div trigerred by a click event continue to work correctly and reference the appropriate content, but none of the jquery outside this div works (such as the navigation).
Here's my jQuery:
var url;
$('.main a').live('click',function() {
url = $(this).attr('href');
$('.secondary').load(url);
return false;
});
Can anyone help me why this isn't working? I think I am supposed to trigger a callback event but I am not sure how to do so. I know this question has been asked multiple times already (usually suggesting to use .live() or .on()), but none of those solutions seemed to work for me.
© Stack Overflow or respective owner