2012-04-11 34 views
1

我在網絡編程經驗僅限於中間,自學成才的JS和jQuery用PHP的衝刺。 ExtJS變成了一個完全不同的動物。使用控制器附加活動(煎茶觸摸/ ExtJS的)

我想不通爲什麼我的控制器沒有做什麼我期望,尤其是因爲我下面是本文檔中使用的語法(這是越來越沒用,因爲他們沒有描述什麼是實際發生的在例子中......但我離題了)。

Main.js

Ext.define("cs.view.Main", { 
     extend: 'Ext.TabPanel', 
     tabBarPosition: 'bottom', 

     requires: [ 
      'cs.view.form', 
      'cs.view.location', 
      'Ext.TitleBar', 
      'cs.controller.geolocate' 
      ], 

     config: { 
      tabBar: { 
       docked: 'bottom', 
      }, 
      defaults: { 
       flex: 1 
      }, 
      items: [ 
       { xtype: 'form' }, 
       { xtype: 'location' } 
       ] 
      }, 
    }); 

form.js

Ext.define('cs.view.form', { 
    extend: 'Ext.form.Panel', 
    requires: 'cs.controller.geolocate', 
    id: 'ClientFinderForm', 

    config: { 
     title: 'Home', 
     iconCls: 'home', 
     items: [ 
     { 
      xtype: 'toolbar', 
      docked: 'top', 
      title: 'Client Finder' 
     }, 
     { 
      xtype: 'textfield', 
      name: 'address', 
      label: 'address' 
     }, 
     { 
      xtype: 'textfield', 
      name: 'dist', 
      label: 'distance(mi)' 
     }, 
     { 
      xtype: 'button', 
      ui: 'confirm', 
      text: 'submit', 
      id: 'submitButton', 
     } 
      ] 
     }, 
}); 

geolocate.js

Ext.define('cs.controller.geolocate', { 
    extend: 'Ext.app.Controller', 

    config: { 
     control: { 
      aButton: { 
       tap: 'message' 
      } 
     },//control 
     refs: { 
      aButton: '#submitButton' 
     },//refs 
    },//config 

    message: function(){ 
     Ext.Msg.alert("Success", "Finally!"); 
    } 
}); 
+0

發生了什麼?你的意思是「不按預期加工」?再清楚不過了,我會幫你 – 2012-04-11 15:44:40

+0

沒有發揮它什麼都不做。我可以通過在form.js中添加'listeners:'來直接添加一個事件 – andyjv 2012-04-11 17:42:06

+0

有一個答案在今天早些時候看起來很有幫助,但它似乎已經消失了......有關將一個'init:'添加到geolocate.js – andyjv 2012-04-11 17:43:01

回答

1

我相信煎茶觸摸2希望喲你把你的應用中的觀點:[]。 JS

而且在你cs.view.form你應該拿出的xtype:「形式」,它已經知道其通過擴展Ext.form.panel的形式。

從您提交按鈕起飛的別名,你需要定義自己的提交按鈕使用別名。

+0

感謝您的提示 – andyjv 2012-04-11 17:38:07