JQuery.event.handle is undocumented and deprecated

I am using a plugin with this block of code. However i get this error

JQMIGRATE: jQuery.event.handle is undocumented and deprecated 

* Reason: jQuery.event.handle has never been documented and deprecated with jQuery 1.7 (see http://forum.jquery.com/topic/deprecated-event-properties-used-in-jquery ). Starting with jQuery 1.9, it has been removed.

Decision. Use jQuery's documented APIs such as .trigger . *

 handler: function( event, execAsap ) { // Save the context var context = this, args = arguments; // set correct event type event.type = "smartresize"; if ( resizeTimeout ) { clearTimeout( resizeTimeout ); } resizeTimeout = setTimeout(function() { jQuery.event.handle.apply( context, args ); //here }, execAsap === "execAsap"? 0 : 50 ); } 

So this line will be changed to what?

 jQuery.event.handle.apply( context, args ); 
+4
source share
2 answers

I assume that context should be an element and args arguments passed to this custom event, so maybe something like this should work:

 $(this).trigger(event, [args]); 

I suggest reorganizing everything to use on instead of bind . Then you can trigger custom events defined with on very easily, I don’t think that with this approach you need to define a custom event so that you can make the code a little smaller.

http://api.jquery.com/on/

+4
source

you can try: instead

  jQuery.event.handle.apply( context, args ); to use jQuery.event.dispatch.apply( context, args ); 

this will work fine ...

0
source

Source: https://habr.com/ru/post/1486128/


All Articles