jQuery's live, when viewed through the $.on
style would have looked like this:
$(document).on("click", "li.bibeintrag", function(){
});
It would listen to click events at the document
level, and determine whether their target matched the second parameter of $.on
. You and I are encouraged to do this our selves, but rather than listening at the document level, we want to listen much closer to the element itself (so the event doesn't need to propagate too far before it's handled).
Since you're responding to clicks on an li
, listen at the level of that items parent:
$("ul#myList").on("click", "li.bibeintrag", function(){
/* Respond */
});
Keep in mind that without providing the second parameter of $.on
, the event handler is bound to the element itself, meaning you don't get the behavior of $.live
which would react to dynamically added elements.