我試圖把一個Sencha Touch 2前端放在一起去Rails後端(返回JSON)。但是,我發現運行以下腳本根本不會聯繫服務器。我相信這個問題有一個非常簡單的解決方案!如果我將該行添加到我的商店:autoLoad: true
,則服務器已聯繫,但我在瀏覽器中看到一個永不結束的加載圖像。Sencha觸摸列表/商店不會聯繫服務器
非常感謝您的幫助!請讓我知道是否有任何更多的信息,你想看到。
--Jared
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'
})
下面介紹一下服務器如果我訪問本地主機迴應:3000 /篇。 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"}
]
}
你在控制檯中得到任何錯誤? – 2012-07-21 10:52:35
@TDeBailleul我看到以下內容: WARN無法確定響應主體的內容長度。設置響應的內容長度或設置Response#chunked = true – 2012-08-04 19:03:36
@TDeBailleul但是,我知道/ articles URL上的操作未執行,因爲它使用puts語句設置,以驗證其執行 – 2012-08-04 19:10:23