2011-11-06 122 views
0

這裏是我的煎茶觀點:Sehch觸摸呼叫控制器挖掘

Ext.application({ 
name: 'Sencha', 
launch: function() { 
    var panel = new Ext.Panel({ 
    fullscreen: true, 
    dockedItems: [ 
     { 
     xtype: "label", 
     dock: "top", 
     html: "<div style='backbround'>KK TEST", 
     style: "width:100%;text-align:center;font-weight:bold" 

     }, 
     { 
     xtype: "toolbar", 
     items: [ 
      { 
      iconMask: true, 
      iconCls: "download" 
      }, 
      { 
      iconMask: true, 
      iconCls: "favorites" 
      }, 
      { 
      iconMask: true, 
      iconCls: "search" 
      }, 
      { 
      iconMask: true, 
      iconCls: "user" 
      } 
     ] 
     }, 
     { 
     xtype: 'list', 
     itemTpl: '{title}', 
     store: { 
      fields: ['title', 'url'], 
      data: [ 
       {title: 'Locate a centre', url: 'ext-scheduler-2-0-upgrading-to-ext-js-4'}, 
       {title: '<a href="/centres" style="color:#FFFFFF;text-decoration:none;">Browse all kwikkopy centres</a>', url: 'sencha-touch-2-what-to-expect'}, 
       {title: 'Sencha Con 2011', url: 'senchacon-2011-now-packed-with-more-goodness'}, 
       {title: 'Documentation in Ext JS 4', url: 'new-ext-js-4-documentation-center'} 
      ] 
     }, 
     itemConfig: { 
      tpl: '{url}' 
     }, 
     listeners: { 
      select: function(itemConfig) { 
      console.log(store) 
      alert('tapped on '+ itemConfig ) 
      } 
     } 
     } 
    ] 
    }); } 
}); 

我想打電話給控制器和重定向到下一個頁面,當我點擊一個列表項。 我該怎麼做?

回答

0

更改你的聽衆在此配置:

listeners:{ 
    itemtap:function(data,index){ 
     var record = data.getStore().getAt(index); 
     // the record that has been clicked. 
     Ext.dispatch({ 
      controller: 'ControllerName' 
      ,action: 'ControllerMethod' 
      ,record: record 
     }); 
    } 
} 
+0

謝謝您的回答和提問的編輯。 我改變了代碼,正如你所說,現在它錯誤''未捕獲TypeError:對象#沒有方法'dispatch''在線調用'Ext.dispatch' – Pravin

+0

您使用的是sencha touch 2嗎?如果是這樣,這就是爲什麼Ext沒有方法'派遣',因爲我還不熟悉ST2我不能幫你。如果你沒有使用sencha touch,那麼檢查你是否包含了sencha touch js文件,並檢查在調用itemtap函數之前是否還有另一個異常。但是你可能使用ST2 .. :) – ilija139

+0

完美..我使用sencha touch 2 ..感謝有價值的信息... – Pravin