Button stops working after loading div via ajax
- by asovgir
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.