You'll have to take the variable up into higher level scope.
(function ($) {
// we expose your variable up here
var settings = {
};
$.fn.myFunction = function (opts) {
// ...instead of down here
// do something with settings, like:
opts = $.extend({}, settings, opts);
}
// you can then access a "shared" copy of your variable even here
if (options) {
$.extend(settings, options);
}
})(jQuery);
If you have to expose it further, you'll just have to work along that same gist.
As a side note however, do note that calling $.extend(settings, options)
will modify the settings
variable. A nice way to do the same thing without modifying the original settings
value is to call $.extend()
on an empty object, and just cache the return like I did in the first $.extend()
call in my example.
var modified_options = $.extend({}, settings, options);