0

I have a jquery plugin I'm writing that has default values, and of course the ability for folks to define their own values for those variables.

var settings = $.extend({
  width:      $(window).width(),
  height:     $(window).height(),
  rotate_btn: $(".rotate_js")
}, options );

Here are what I have for the current defaults. What I'm having trouble with is I'd like for these values to be updated on the window resize, either the default value or the value defined by the person using the plugin. How would you go about doing that so it happens within the plugin?

Thanks in advance for any help with this.

1 Answer 1

1

var settings = $.extend({
    width: $(window).width(),
    height: $(window).height(),
    rotate_btn: $(".rotate_js")
}, options );

$(window).on('resize.myCustomEventName', function(event) {
        $.extend(settings, {
            width: $(window).width(),
            ...
        });
});

Sign up to request clarification or add additional context in comments.

1 Comment

would this also take into account the options defined by a user when initializing the plugin?

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.