4
在Knockout.js我創建一個observableArray推車型爲:Knockout.js observableArray vs Backbone.js Collection - 有什麼區別?
function Room(data) {
this.name = ko.observable(data.name);
}
function RoomViewModel() {
var self = this;
self.rooms = ko.observableArray([]);
self.newRoomText = ko.observable();
self.addRoom = function() {
self.rooms.push(new Room({ name: this.newRoomText() }));
self.newRoomText("");
$("#modal").dialog("close");
}.bind(self);
}
在Backbone.js的我想創建一個集合來存儲我的模型:
var Book = Backbone.Model.extend();
var Books = new Backbone.Collection([
{name: "Abe Lincoln - Vampire Hunter"}
{name: "Pride and Prejudice and Zombies"}
]);
剛剛是多麼的不同,這些2層結構從彼此?
爲了使這些數據結構與標準的JavaScript數組不同,到底什麼是幕後?
謝謝 - 兩者是概述很有幫助。 – PhillipKregg 2012-01-06 02:20:08