JQuery 1.9.1 $ .event.handle.apply alternative

I recently upgraded one of my projects to jQuery 1.9.1, and I can no longer use the method $.event.handle.apply(). I searched and found that I can host jquery.migrate.js. I just want to confirm if there is another option? My google-fu doesn't work here ...

- EDIT - here is the code (not mine ... copied from the plugin) causing the problem ...

// Event handler function
function mouseWheelHandler(event)
{
    var sentEvent = event || window.event,
        orgEvent = sentEvent.originalEvent || sentEvent,
        args = [].slice.call( arguments, 1 ),
        delta = 0,
        deltaX = 0,
        deltaY = 0;
        event = $.event.fix(orgEvent);
        event.type = "mousewheel";

    // Old school scrollwheel delta
    if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
    if ( orgEvent.detail     ) { delta = -orgEvent.detail/3; }

    // New school multidimensional scroll (touchpads) deltas
    deltaY = delta;

    // Gecko
    if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
        deltaY = 0;
        deltaX = -1*delta;
    }

    // Webkit
    if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
    if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }

    // Add event and delta to the front of the arguments
    args.unshift(event, delta, deltaX, deltaY);

    return $.event.handle.apply(this, args);
}
+5
source share
5 answers

or you can try:

$. event. sending .call (obj, event);

+8
source

I found this thread looking for a solution for Infinite Scroll that does not work with jQuery 1.9. * and causes the same error as in the original message.

JQNinja comment : $.event.handle.apply $.event.dispatch.apply Infinite Scroll. , .

, , , , , , , , , !

+3

. - :

642 js :

event.type = 'lastclick';
$.event.handle.apply(Me, [event,clicks])

:

event.type = 'lastclick';
event.isPropagationStopped = function() { return false };
$.event.handle.apply(Me, [event,clicks])

, isPropagationStopped, !

, .

0

i The solution is found here, I am testing it and it works great. Get mouse wheel events in jQuery?

$(document).ready(function(){
    $('#foo').bind('mousewheel', function(e){
        if(e.originalEvent.wheelDelta /120 > 0) {
            $(this).text('scrolling up !');
        }
        else{
           $(this).text('scrolling down !');
        }
    });
});
0
source

change this line:

return $ .event.handle.apply (this, args);

at

return jQuery .event.handle.apply (this, args);

-3
source

All Articles