ウィジェットファクトリを作成しましたが、パブリックメソッドでそのオプションまたはメソッドにアクセスしたいのですが、エラー「142 Uncaught TypeError:Object hasnomethod」または「cannotreadproperty」が返されます。正しくアクセスするには?
次に例を示します。
function($){
$.widget("demo.myWidget",{
options:{
myVar:0
},
_create:function(){
//this line work in here
alert(this.options.myVar);
},
calledFunction : function(){
alert(this._getVar());
},
pubFunction : function(){
setInterval(this.calledFunction, 1000);
},
_getVar : function(){
return this.options.myVar;
}
});
}(jQuery));
$(document).ready(function(){
$("selector").myWidget();
$("selector").myWidget("pubFunction");
});
_createメソッドのオプションにアクセスすると、正常に機能します。よろしくお願いします。