我是 moootools 的新手,我正在创建一个模板类,这是我的代码 -
var Template = new Class({
Singleton : true,
template : '',
/* gets the component type template */
get : function(componentType){
var tplUrl = Core.getUrl('backend') + 'response/' + componentType + '/get_template.php',
that = this,
request = new Request({url: tplUrl, method : 'get',onSuccess : function(responseText){
that.template = responseText;
return that;
}}).send();
}
});
我想做的是:
var tpl = new Template();
tpl.get('component').setTemplateData({name:'yosy'});
问题是当我调用此代码时:
var tpl = new Template();
console.log( tpl.get('component') );
我没有得到我当前的模板对象,我得到的是'未定义'。
我怎样才能使这个可链接?