how to get jquery on() to work on not-yet-existing elements -
i have used delegate() bind events elements don't exist when dom loaded. understand on() supposed replace delegate, don't understand documentation on jquery site how translate following code use on()
$(document).delegate( ".course_name, .start_date, .book_title, .book_author, .book_isbn", "click", function() { var whichbutton = $(this).attr("class"); make_table(whichbutton); fillisbn(); });
$(document).on("click", ".course_name, .start_date, .book_title, .book_author, .book_isbn", function() { var whichbutton = $(this).attr("class"); make_table(whichbutton); fillisbn(); });
not hard, it?
internally nowdays .delegate
reference .on
. .delegate
implemented as
function (selector, types, data, fn) { return this.on(types, selector, data, fn); }
Comments
Post a Comment