首页 新闻 会员 周边

extjs自定义函数不能执行

0
悬赏园豆:10 [待解决问题]

var win = Ext.create('Ext.window.Window', {
                title: '登录',
                iconCls: 'locked',
                width: 400,
                height: 260,
                layout: 'fit',
                items: form,
                buttonAlign: 'center',
                resizable: false,
                closable: false,
                draggable: false,
                buttons: [{
                    text: '登录',
                    handler: this.LoginFrom,
                    scope: this
                }, {
                    text: '重置',
                    handler: function () {
                        form.getForm().reset();
                    },
                    scope: this
                }],
                LoginFrom: function () {
                    alert();
                }
            });

LoginFrom为什么不能调到LoginFrom()弹出对话框。

顺德人的主页 顺德人 | 初学一级 | 园豆:33
提问于:2012-10-24 22:31
< >
分享
所有回答(2)
0

handler: Ext.window.Window.LoginFrom,

 

应该是this的问题,你可以看看你的代码调用的地方this指向什么?

chenping2008 | 园豆:9836 (大侠五级) | 2012-10-25 13:42

没有this的话还找不到对象。

支持(0) 反对(0) 顺德人 | 园豆:33 (初学一级) | 2012-10-25 21:23

@顺德人: handler:

 Ext.create('Ext.window.Window', {
                title: '登录',
                iconCls: 'locked',
                width: 400,
                height: 260,
                layout: 'fit',
                items: form,
                buttonAlign: 'center',
                resizable: false,
                closable: false,
                draggable: false,

that:this,
                buttons: [{
                    text: '登录',
                    handler: that.LoginFrom,
                    scope: this
                }, {
                    text: '重置',
                    handler: function () {
                        form.getForm().reset();
                    },
                    scope: this
                }],
                LoginFrom: function () {
                    alert();
                }
            });

试试

支持(0) 反对(0) chenping2008 | 园豆:9836 (大侠五级) | 2012-10-25 22:15

@chenping2008: 一样不行

支持(0) 反对(0) 顺德人 | 园豆:33 (初学一级) | 2012-10-26 19:55
0

问题得以解决。

顺德人 | 园豆:33 (初学一级) | 2013-03-25 21:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册