I understand that .live() has been removed from jQuery 1.9 and that .on() should be used instead. So far .on() has worked perfectly for me if the selector is a string. For example,
$("a.offsite").live("click", function(){ alert("Goodbye!"); });
turned into
$(document).on("click", "a.offsite", function(){ alert("Goodbye!"); });
But how do I use .on() for a JQuery selector object (or a collection of objects) as follows?
var jele = $('.nav').find("a.offsite");
$(jele).live("click", function(){ alert("Goodbye!"); });
turned into
var jele = $('.nav').find("a.offsite");
$(document).on("click", jele, function(){ alert("Goodbye!"); });
Is the code above converted correctly? The problem I encounter is other event handlers bound to the same event yet different selector are also executed when the event fires. Hence I suspect this is not the correct way but I can't find any similar example in the official documentation.
I know I could have passed the selector string instead of the jele object into .on() method but in some cases I simply do not have access to the selector string, eg. when the jele object is passed as an argument into the function in which the binding occurs.