I have got this jquery code:
$(document).ready(function(){
$('a').bind('click', false);
var url;
$('a').on('click',function(e){
url=$(this).attr('href'); //;
$('#AjaxPage').load(url+" .AjaxContent");
});
});
The problem is the click event works the first time .. but on the content loaded from the loaded function , the links there dont have the click event i binded .. why is that?
I thought you use ‘on’ as you would use ‘live’
Update:
Now my load function doesnt get executed:
$(document).ready(function(){
$('a').bind('click', false);
var url;
$(document).on('click', 'a',function(){
url=$(this).attr('href'); //;
$('#AjaxPage').load(url+" .AjaxContent");
});
});
Replace
with
Contrary to
live,onwill handle events in a jQuery collection and delegates the event to the target verifying the supplied selector. The jQuery collection must be non empty. It can be more precise thandocument, of course, but must be a parent of the element you’re adding and on which you wish to intercept the event.