Possible Duplicate:
jQuery - convert .live() to .on()
JQuery ‘on’ vs. ‘live’
Turning live() into on() in jQuery
I know .live() is deprecated, but .on() is getting me some errors. It does not work when I dynamically generate the dome, it only works at the first click. Whilst the same code with .live() works correctly. I'm using jquery 1.8
Working code
$('.item').live('click', function(e) {
alert('test');
// ajax call that regenerates .item element
});
This code only works at the first click:
$('.item').on('click', function(e) {
alert('test');
// ajax call that regenerates .item element
});
What's wrong?