ExtJS 按钮处理
向按钮添加功能的最佳方法是什么? (特定范围)
肮脏的例子:
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”是一个选项)
What is the best way to add a function to a button? ( specfically scoped )
Dirty example:
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
}
});
I've seen examples in ExtJs 4 using
this.up('form').reset();
and I can also
this.ownerCt.ownerCt.reset()
But both those feel very awkward somehow. ( the .up much less so, though since I am playing with touch , i dont think "up" is an option)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用这个
Use this