2014-01-10 28 views
0

我的服務器返回:採集元數據以下JSON

{ 
"total":100, 
"posts":[//an array contains 10 posts.] 
} 

使用默認骨幹API,一集的URL應該返回的模式陣列。將帖子總數發送到使用此類收藏的視圖的正確方式是什麼?

+0

擡起頭,我刪除了正則表達式標籤和骨幹加入標籤。 – brandonscript

+0

你已經有了'parse'方法來解開'posts',對嗎? –

+0

@ muistooshort在提問之前我嘗試過使用'parse'方法。它有助於檢索'posts'屬性,但我也需要在我的視圖中使用'total'。 – PHPst

回答

0

試着這麼做:

parse: function(response){ 
    this.total = response.total; 
    return response.posts; 
} 
+0

'set'的第一個參數需要一個模型。該集合不支持屬性。 – PHPst

+0

糟糕,編輯了我的答案。您可以通過'myCollection.total'訪問總數。 –