我最近将我的一个项目更新为jQuery 1.9.1,我不能再使用$.event.handle.apply()方法了.我搜索并发现,我可以放置
jquery.migrate.js.我只是想确认是否还有其他选择?我的google-fu在这里失败了……
–EDIT–这是导致问题的代码(不是我的……从插件中复制而来)……
// 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); }
解决方法
或者你可以尝试:
$.event.dispatch.call( obj,event );