2011-11-12 13 views

答えて

1

コードの構造は、xtypesとして登録しているコンポーネントを格納する場所を許可する必要があります。また、アプリケーションを構成するコンポーネントのトップレベルの名前空間も必要です。こうすることで、いつでもアプリの部品を参照することができます。コントローラロジックを分解することも良い考えです。小さなアプリの場合、1つのコントローラーがうまくいくかもしれませんが、アプリが大きくなると、それぞれのコントローラーを1つずつ持つことができます。

ここには、この例で入力したコードの修正版があります。成功イベントを処理し、上記の推奨事項に適合するように構成されています。

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() 
    }) 
+0

tnx.what about buttons.howボタンを定義できます。 –

+0

ボタンではありません!私の歯茎ドロップボタンではありません! http://www.youtube.com/watch?v=FpBJih02aYU – HDave

関連する問題