I have a JavaScript file - MyJavascript.js - that is included in various web applications. The problem is that in one application I use JQuery v1.5.1, where the "Live" function works just fine, but in another application, since I use Bootstrap, I use v2.1.1., where "on" works and "live" doesn't.
Is there any way that I can write my JS file in a way that it works for Both the versions of JQuery?
++ Abhay
Thanks for the answers.
The problem of attaching the events to Dynamically Added elements still remained. So, I wrote down a Javascript function instead as follows :
function compatibleOn(event, selector, handler) {
if (typeof jQuery().on === 'function') {
$(document).on(event, selector, handler);
} else {
$(selector).live(event, handler);
}
};