Class extjs调用类上的Ext.onReady函数
我有这个结构:Class extjs调用类上的Ext.onReady函数,class,function,extjs,call,extjs3,Class,Function,Extjs,Call,Extjs3,我有这个结构: Example.Form = Ext.extend(Ext.form.FormPanel, { // other element , onSuccess:function(form, action) { } } Ext.reg('exampleform', Example.Form); Ext.onReady(function() { var win = new Ext.Window({ id:'formloads
Example.Form = Ext.extend(Ext.form.FormPanel, {
// other element
, onSuccess:function(form, action) {
}
}
Ext.reg('exampleform', Example.Form);
Ext.onReady(function() {
var win = new Ext.Window({
id:'formloadsubmit-win'
,items:{id:'add', xtype:'exampleform'}
});
win.show();
})
我删除了上面的额外代码
我想这样做:当我在示例中提交函数->onSuccess上的表单时。表单类能够关闭主体上的窗口。(提交成功结果后,打开的窗口主体将关闭)
很抱歉我的英语不好。代码的结构应该允许一个位置来存储您注册为xtypes的组件。它还应该为组成应用程序的组件提供顶级命名空间。这样,您就可以始终引用应用程序的各个部分。打破控制器逻辑也是一个好主意。对于一个小应用程序,一个控制器可以很好地工作,但一旦应用程序增长,最好为应用程序设置多个控制器,每个控制器一个 下面是您在该示例中输入的代码的修改版本。它将处理成功事件,其结构符合上述建议
Ext.ns('Example');
/* store components to be used by app */
Ext.ns('Example.lib');
/* store instances of app components */
Ext.ns('Example.app');
Example.lib.Form = Ext.extend(Ext.form.FormPanel, {
// other element
// moved to app controller
//onSuccess:function(form, action) {
//}
});
Ext.reg('exampleform', Example.lib.Form);
Example.lib.FormWindow = Ext.extend(Ext.Window,{
initComponent: function(){
/* add the items */
this.items ={itemId:'add', xtype:'exampleform'};
/* ext js requires this call for the framework to work */
Example.lib.FormWindow.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg('exampleformwin', Example.lib.FormWindow);
/*
manage/control the app
*/
Example.app.appController = {
initApp: function(){
Example.app.FormWindow = Ext.create({xtype:'exampleformwin', id:'formloadsubmit-win'});
Example.app.FormWindow.show();
/* get a reference to the 'add' form based on that item id and bind to the event */
Example.app.FormWindow.get('add').on('success', this.onAddFormSuccess, this );
},
/* the logic to handle the add-form's sucess event */
onAddFormSuccess: function(){
Example.app.FormWindow.hide();
}
}
Ext.onReady(function() {
/* start the app */
Example.app.appController.initApp()
})
那按钮呢。我如何定义按钮。不是按钮!不是我的口香糖扣子!