0

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();
});

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, its always the simple things isnt it. Thanks! ill check the answer as soon as it lets me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.