我正在使用CanJS編寫SPA,其中包含一個列表,用戶可以添加該列表。我想通過將其寫入文件來永久存儲新添加的項目。有人能幫我嗎?CanJS將文件保存到文件
'.btn_save click': function (ele, ev) {
var self = this;
var val = this.$input.val();
// get the currently selected model
var model = this.state.attr('selected');
// store if it is new
var isNew = model.isNew();
// update the attributes
model.attr('name', val);
// save it
model.save(function (library) {
if (isNew) {
// if new then append it to the list
self.libraries.push(library);
}
self.resetSelected();
});
return false;
},
這會爲當前瀏覽會話臨時保存該項目。我想永久保存它。
有人可以幫助我學習CanJS。我很困惑使用CanJS。 – 2013-03-12 10:04:54