2013-04-07 60 views
12

我試圖保持一個對象文字數組與服務器數據同步。這些對象通過backbone.googlemaps擴展名被放置在谷歌地圖上。Backbone.js - 如何從一個集合中獲取對象文字的數組?

我有一個集合:

var LocationList = Backbone.Collection.extend({ model: Location, url: '/locations' })

我怎麼能抓住對象文本從這個LocationList集合數組?我的目標是這樣的:

[{name: "Home", address: "123 Pleasant St"}, {name: "Work", address: "123 Unpleasant St"}]

回答

22

您正在尋找收集.toJSON()方法,see here

var locations = new LocationList(); 

locations.toJSON(); 
相關問題