I’m currently converting my live events to use on with jquery 1.7+.
I’ve simply changed live to on like so:
Before:
$('.commentopen').live('click', function() {
var ID = $(this).attr("id");
$("#commentbox"+ID).slideToggle('fast');
return false;
});
After:
$('.commentopen').on('click', function() {
var ID = $(this).attr("id");
$("#commentbox"+ID).slideToggle('fast');
return false;
});
on works after a page load but fails to trigger after I add new data dynamically. Am I missing something?
You still need to use delegation