javascript - 我无法将数据从 Controller 传递到 Sencha Touch 2.4 中的 View

标签 javascript model-view-controller sencha-touch sencha-touch-2 senchatouch-2.4

我尝试了一些不同的方法,但无法将数据从 Controller 传递到 View (到容器内的组件)。

这里我有 View ServisDetail.js :

Ext.define('Asistan.view.ServisDetail', {
    extend: 'Ext.Container',
    xtype: 'servisDetail',
    config: {
        layout: 'fit',
        items : [
            {
                xclass : 'Asistan.view.ServisToolbar'
            },
            {
                // "data: {}" is needed to work. I try to pass data from controller to here
                xtype: 'component',
                tpl: Ext.create('Ext.XTemplate','{URUN_CIHAZ_ADI} jkjk')
            }
        ]
    }
});

这是我的 Controller Servis.js认为认为它应该有效。但它不传递数据:

Ext.define('Asistan.controller.Servis', {
    extend: 'Ext.app.Controller',
    config: {
        refs: {
            servis: 'servisNavigationView servisContainer list',
        },
        control: {
            servis: {
                itemdoubletap: 'showServis'
            }
        }
    },
    showServis: function(item, index, e, eOpts) {
        this.servis = Ext.widget('servisDetail');
        this.servis.config.items[1].data = eOpts.data; // <- Here! It doesn't work. console.log shows that the data is there but in the browser the data doesn't show up.
        console.log(this.servis.config.items[1].data); // I can see my data here, right before the push
        item.up('servisNavigationView').push(this.servis);
    }
});

我缺少什么?

最佳答案

尝试使用

showServis: function(item, index, e, eOpts) {
    this.servis = Ext.widget('servisDetail');
    this.servis.setData(eOpts.data);  // setData applies the data to the container template.
    item.up('servisNavigationView').push(this.servis);
}

关于javascript - 我无法将数据从 Controller 传递到 Sencha Touch 2.4 中的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31200809/

相关文章:

asp.net - Sencha Touch 错误您正在尝试解码 ASP.NET 中返回的无效 JSON 字符串 HTML 页面

javascript - Node.js MySQL 查询执行流程

ios - 我应该使用尽可能多还是尽可能少的 View / View Controller ?

javascript - 应用模板后,sencha 触摸面板不会滚动

java - 从简单的 JSP spring MVC 页面获取值(value)

php - 自定义组件后端中的 Joomla 3.0 MVC 文件上传

javascript - 在面板sencha touch中设置组件的html

javascript - 使用 javascript/css 将 64 位字符串转换为 jpeg

javascript - 如何在 Android 上的 SDCard 上打开 HTML 文件

javascript - 如何取消选中复选框并删除验证