My chances are slim with this but I've tried a couple of solutions via Google but nothing seems to fix the 'Uncaught TypeError: Cannot call method 'apply' of undefined ', anonymous function:
It works if on its own with no other JS but when combined on the same page as other scripts I get the error.
The lines of code it refers to are the following with line 32 being the culprit. Line 32 is this line - if ( resizeTimeout ) { clearTimeout( resizeTimeout ); }
:
var $event = $.event, resizeTimeout;
$event.special.smartresize = {
setup: function() {
$(this).bind( "resize", $event.special.smartresize.handler );
},
teardown: function() {
$(this).unbind( "resize", $event.special.smartresize.handler );
},
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 );
}, execAsap === "execAsap"? 0 : 100 );
}
};
I managed to figure this out by looking at the code, there is a method called "simulate" which you can use to "Piggyback on a donor event to simulate a different one.", "Fake originalEvent to avoid donor's stopPropagation, but if the simulated event prevents default then we do the same on the donor." This struck me as the purpose of "setting the event type in Brandon Aaron's tutorial
Instead of:
event.type = "myType";
jQuery.event.handle.apply(this, arguments);
Use:
jQuery.event.simulate('myType', this, event);
Guessing you're loading a newer version of jQuery. It appears as though jQuery 1.9
and later does not have the jQuery.event.handle
property.
To my knowledge, this was never a supported property.
http://jsfiddle.net/xPJN4/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With