0

My controller seems that it doesnt work : Controller:

 Ext.define('MyApp2.controller.Details',{
extend : 'Ext.app.Controller',

config: {
    refs:{
         NewsContainer: 'NewsContainer'

    },
    control:{
        'NewsContainer home list':{
            itemtap: function(){
                console.log("item");
            }
        }

    }

}


});

Home :

 Ext.define('MyApp2.view.Home', {
extend: 'Ext.Panel',
xtype: 'home',
requires: [
    'Ext.tab.Panel',
    'Ext.dataview.List',
    'MyApp2.view.NewsContainer'

],
config: {
    title: 'Home',
    IconCls:'home',
    styleHtmlCls:'details',
    styleHtmlcontent:'true',
    scrollable:true,
    layout:'fit',
    items: [
        {
                    xtype: "list",
                    store: "NewsStore",
                    itemTpl: new Ext.XTemplate (
                                                    '<div>',
                                                    '<img src="{enclosure}" />',
                                                    '<h1>{title}</h1>',
                                                    '</div>'
                                                ),
                   itemCls:'news-entries'                                 

                  }
             ]
}
 });

NewsContainer:

 Ext.define('MyApp2.view.NewsContainer', {
extend: 'Ext.NavigationView',
xtype: 'NewsContainer',

config: {
    autoDestroy: false,
            title: 'Home',
            IconCls:'Home',

        items: [
            {
                xtype:'home' 
            }
        ]
}
 });

and here is my app.js:

 Ext.application({
name: 'MyApp2',

requires: [
    'Ext.MessageBox'

],
controller:['Details'],
models:['MyApp2.model.News'],

views: [
    'Main','Home','News','NewsContainer','Details'
],

stores:['NewsStore'],

icon: {
    '57': 'resources/icons/Icon.png',
    '72': 'resources/icons/Icon~ipad.png',
    '114': 'resources/icons/Icon@2x.png',
    '144': 'resources/icons/Icon~ipad@2x.png'
},

isIconPrecomposed: true,

startupImage: {
    '320x460': 'resources/startup/320x460.jpg',
    '640x920': 'resources/startup/640x920.png',
    '768x1004': 'resources/startup/768x1004.png',
    '748x1024': 'resources/startup/748x1024.png',
    '1536x2008': 'resources/startup/1536x2008.png',
    '1496x2048': 'resources/startup/1496x2048.png'
},

launch: function() {
    // Destroy the #appLoadingIndicator element
    Ext.fly('appLoadingIndicator').destroy();

    // Initialize the main view
    Ext.Viewport.add(Ext.create('MyApp2.view.Main'));
},

onUpdated: function() {
    Ext.Msg.confirm(
        "Application Update",
        "This application has just successfully been updated to the latest version. Reload now?",
        function(buttonId) {
            if (buttonId === 'yes') {
                window.location.reload();
            }
        }
    );
}
  });

Can u tell me please what's wrong with my code ?there is no error in the console , nothing's happened when i tap :(

4

2 回答 2

3

问题是,控制器没有找到对列表的引用。没有错误消息,因为未捕获列表中的 itemtap 事件。

我认为这个控制器代码会起作用:

Ext.define('MyApp2.controller.Details',{
  extend : 'Ext.app.Controller',
  config: {
      refs:{
         homeList: 'home list'
      },
      control:{
         homeList : {
            itemtap : function(list, index, item, record) {
                console.log("item");
            }
         }
      }
  }
});
于 2013-05-27T09:05:06.563 回答
0

添加 itemId : list 在视图和控制器中的下一行: main : 'main ,这对你来说已经足够了......

 Ext.define('MyApp2.controller.Details',{
  extend : 'Ext.app.Controller',
  config: {
      refs:{
         main : 'main',
         homeList: 'main list'
      },
      control:{
         homeList : {
            itemtap : function(list, index, item, record) {
                console.log("item");
            }
         }
      }
  }
});
于 2014-07-24T14:10:52.890 回答