admin管理员组

文章数量:1405553

I am using a plugin that has this block of code. However i am getting this error

   JQMIGRATE: jQuery.event.handle is undocumented and deprecated

*Cause: jQuery.event.handle was never documented, and deprecated with jQuery 1.7 (see ). As of jQuery 1.9, it has been removed.

Solution: Use documented jQuery 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 );

I am using a plugin that has this block of code. However i am getting this error

   JQMIGRATE: jQuery.event.handle is undocumented and deprecated

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

Solution: Use documented jQuery 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 );
Share Improve this question asked Jun 13, 2013 at 22:35 anvdanvd 4,05720 gold badges71 silver badges129 bronze badges 2
  • What plugin? I guess context must be the element and args the arguments passed into that custom event, so something like this $(this).trigger(event, [args]) maybe? – elclanrs Commented Jun 13, 2013 at 22:38
  • @elclanrs, you are correct. please add as an answer. link – anvd Commented Jun 13, 2013 at 22:42
Add a ment  | 

2 Answers 2

Reset to default 4

I'm guessing context must be the element and args the arguments passed into that custom event, so maybe something like this should work:

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

I would suggest refactoring the whole thing to use on instead of bind. Then you can trigger custom events defined with on very easily, I don't think using this approach you need to define a custom event so you could make the code a bit smaller.

http://api.jquery./on/

you could try this: instead of

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

jQuery.event.dispatch.apply( context, args );

this will work fine...

本文标签: javascriptjQueryeventhandle is undocumented and deprecatedStack Overflow