我正在使用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