Reputation: 31
I am in the process of upgrading jQuery from 1.12.3 to 3.5.1(latest version). My application is large and we have jQuery version 1.12.3. While upgrading with help of jQuery migration script, have faced few technical challenges:
jQuery.fn.live = function( types, data, fn ) {
try{
if(typeof(this.selector) == "undefined" && typeof(this[0].id) != "undefined"){
this.selector = String("#" + this[0].id);
}
}catch(e){
}
if(typeof(this.context) == "undefined"){
this.context = jQuery(this).parent();
}
else{
this.context = "body";
}
jQuery( this.context ).on( types, this.selector, data, fn );
return this;
};
It's working well. when using the same technique for Die() it is not working. because for example
$(".selector").die().live("click",function(){}).
We can't get events and selector for the die function. So I dropped this option. Is there's any other way to upgrade jQuery with minimal code changes?
or
If I change the on() and off() method manually, How can I ensure the events are working properly instead of manual testing. Since manual code replacement and testing will impact out web app development road map timeline.
Upvotes: 3
Views: 3323