0

我正在尝试使用 EXT JS 4、Sencha Touch 2.0 和 WebORB。

我正在尝试通过 Ext 动态地在 Sencha Touch 的 MVC 中建立一个商店。我在 Index.html 的部分中调用了以下 javascript 函数,如下所示:

<script src="sencha-touch-all.js"></script>
                <script src="webORB.js"></script>
                <script>
                var dataFetched;
                var dataGet=function(){
        <!--  Class Name and URL are replaced in the original program-->
                this.proxy = webORB.bind("ClassName", "URL");
                    dataFetched=this.proxy.GetClassList(1301722);   
                //console.log(dataFetched);
            }
                </script>
                <script src="app.js">
</script>

以下是我的app.js

Ext.Loader.setConfig({
    enabled: true

});
Ext.application({
    name: 'SBR',
    controllers: [
        'Main','Blog','Comments'
    ],
    views : [
    'Home','Blog', 'Comments'
],
    models : ['Comments'],
    stores: ['Comments'],
    launch: function(){
        dataGet();
        console.log(dataFetched);
        Ext.create('SBR.view.Viewport');
    }
});

以下是我的 Comment.js - 商店

Ext.define('SBR.store.Comments',{
    extend: 'Ext.data.Store',   
    config: {
        model: 'SBR.model.Comments',
        data: dataFetched
    }

});

以下是 Comment.js - 模型

Ext.define('SBR.model.Comments',{
        extend: 'Ext.data.Model',

        config: {
            //fields: ['subject','body']
            fields: ['bookImageUrl','authorFirstName','authorLastName']
        }
    })

以下是 Comment.js - 查看

Ext.define('SBR.view.Comments',{
    extend: 'Ext.List',
    xtype: 'commentspage',
    config:{
        title: 'Comments',
        iconCls: 'star',
        //indexBar: true,
        store : 'Comments',
        itemTpl: '{authorLastName}',
        onItemDisclosure: function(item) {
            console.log('Disclose more info on' + " " + item.data.subject);
        }
    }
});

如果我使用静态 Json Data 定义存储,它工作正常,但是当我尝试使用 WebORB 访问它时它不会。

控制台条目在向控制台显示数据之前完成。为什么它没有在评论视图中显示任何数据,或者我的方法通过 WebORB 收集和加载数据到商店是完全错误的?

4

1 回答 1

0

哦,是的……我明白了……

我刚刚更改了以下内容:

  1. 我将函数 dataget() 从 index.html 转移到 Comments.js-Store 并在同一文件的配置中调用相同的函数,例如:

数据:数据获取()

就是这样。。成功了。。

于 2013-05-20T06:02:00.897 回答