2011-11-06 125 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