Reputation: 1764
I've created a custom jQuery plugin and having issues getting the window resize function to fire within the plugin. Broke it down to the basics of what I got, can't figure out why it's not firing:
;(function ( $, window, document, undefined ) {
$.fn.test = function(options) {
$(window).resize(function() {
alert('sdsd');
});
};
})(jQuery);
$(function() {
$('.element').test();
});
Upvotes: 0
Views: 1393
Reputation: 95066
In your case window
is undefined because you aren't passing it into the function.
;(function ( $, window, document, undefined ) {
$.fn.test = function(options) {
$(window).resize(function() {
alert('sdsd');
});
};
})(jQuery, window, document); //<--- changes here
Upvotes: 4