【发布时间】:2011-11-02 02:51:47
【问题描述】:
向按钮添加功能的最佳方式是什么? (具体范围)
脏例子:
form.Login= function(config){
if ( typeof config !== 'object' ) { config = {}; }
var tbarBottom = {
xtype: 'toolbar',
dock: 'bottom',
items: [{
xtype:'spacer'
},{
text: 'Reset',
handler:function(button,event){
console.log(this); // ehh... how do I this.reset() from here?
//( "this" is the buttons scope, not the forms scope )
}]
}
config.dockedItems= [tbarBottom];
form.Login.superclass.constructor.call(this,config);
Ext.extend( form.Login, Ext.form.FormPanel,{
reset: function() {
this.reset()// I want to call this function
}
});
我在 ExtJs 4 中看到了使用
的示例this.up('form').reset();
我也可以
this.ownerCt.ownerCt.reset()
但不知何故,这两个人都觉得很尴尬。 (.up 少得多,虽然因为我玩的是触摸,我不认为“up”是一个选项)
【问题讨论】:
标签: function extjs scope sencha-touch extend