I am making a module for the Joomla! page of a client that uses Ajax to render different queries to the database. The result of these queries is that I regenerate the entire
Bind the event handler on a parent element and use event delegation to handle the events. By binding the event handler on a parent element you don't need to bind it on all the child elements.
/HTML/
/Javascript/
// use this
$("#container").on("click", ".click", function(){
alert(this.id + ": I've been clicked.");
});
// don't use this
$(".click").on("click", function(){
alert(this.id + ": I've been clicked.");
});