以下は、私がやろうとしていることの疑似例です
非厳密モードではこれは機能しますが、厳密モードでは setInterval が起動すると未定義エラーが発生します。このスクリプトは、init セクションを呼び出すプラグインとして別の jquery スクリプトから呼び出されます。
here を読むと、グローバルスコープ/コンテキストの問題のように見えますが、続行する方法がわかりません
(function($, window, document) {
'use strict'; // remove and things work
var opts,test;
test = function(options) {
opts = $.extend(test.prototype.opts, test.prototype.defaults, options);
};
test.prototype.Save = function () {
console.log('hi');
};
test.prototype.defaults = {
_interval_id: null
};
test.prototype.opts = {};
$.bla.plugins.foobar = function() {
var base = this,
bar;
base.init = function() {
bar = new test();
opts = test.prototype.opts;
bar.Save(); // works
opts._interval_id = setInterval('bar.Save();', 10000); // called but bar is not defined
};
};
})(jQuery, window, document);