0

Sencha Touch 2 のフロント エンドを Rails のバック エンド (JSON を返す) と組み合わせようとしています。ただし、次のスクリプトを実行してもサーバーにまったく接続しないことがわかりました。この問題には非常に簡単な解決策があると確信しています。次の行をストアに追加するとautoLoad: true、サーバーに接続されますが、ブラウザーに終わりのない読み込み中の画像が表示されます。

助けてくれて本当にありがとう!他に知りたい情報があれば教えてください。

--ジャレッド

index.js

ListDemo = new Ext.Application({

name: "ListDemo",

launch: function() {

    ListDemo.listPanel = new Ext.List({
        id: 'disclosurelist',
        store: ListDemo.ListStore,
        itemTpl: '<div class="contact">{title}</div>',
        onItemDisclosure: function(record, btn, index) {
            ListDemo.detailPanel.update(record.data);
            ListDemo.Viewport.setActiveItem('detailpanel');
        }
    });

    ListDemo.Viewport = new Ext.Panel ({
        fullscreen: true,
        layout: 'card',
        cardSwitchAnimation: 'slide',
        items: [ListDemo.listPanel]
    });

}
});

data.js

Ext.regModel('Article', {
        fields: [
            {name: 'title',       type: 'string'},
                    {name: 'url',     type: 'string'}
        ],
        proxy: {
          type: 'rest',
          url : 'articles',
            format: 'json',
          reader: {
              type: 'json',
              root: 'articles',
                record: 'entry'
          }
      }
});

ListDemo.ListStore = new Ext.data.Store({
        model: 'Article'
})

localhost:3000/articles.json にアクセスすると、サーバーは次のように応答します。

{"articles":
    [
        {"created_at":"2012-07-18T23:54:08Z","from":null,"id":1,"image":"","title":"Inquiry Seeks Accomplices of Bomber in Bulgaria","updated_at":"2012-07-21T06:13:54Z","url":"www.newyorktimes.com"},
        {"created_at":"2012-07-19T00:01:35Z","from":null,"id":2,"image":"","title":"Changing Harlem Celebrates Queen of Soul Food","updated_at":"2012-07-21T06:26:13Z","url":"www.newyorktimes.com/harlem"}
    ]
}
4

1 に答える 1

0

サーバー スクリプトは、次のような JSON を返す必要があります。

{
    "success": true,
    "articles": [
        {"created_at":"2012-07-18T23:54:08Z","from":null,"id":1,"image":"","title":"Inquiry Seeks Accomplices of Bomber in Bulgaria","updated_at":"2012-07-21T06:13:54Z","url":"www.newyorktimes.com"},
        {"created_at":"2012-07-19T00:01:35Z","from":null,"id":2,"image":"","title":"Changing Harlem Celebrates Queen of Soul Food","updated_at":"2012-07-21T06:26:13Z","url":"www.newyorktimes.com/harlem"}
    ]
}
于 2012-07-22T08:39:40.787 に答える