我正在尝试在我的应用程序中实现backbone.localstorage(https://github.com/jeromegn/Backbone.localStorage),但由于某种原因它包含它但实际上并未将任何内容保存到localStorage,但它也没有抛出任何错误任何一个。
这是我的模型代码(我正在使用 RequireJS):
define([
'backbone',
'common',
'localstorage'
],
function(Backbone, Common) {
//Define the App Namespace before anything else
var APP = Common.app_namespace || {};
APP.Models.ExampleModel = Backbone.Model.extend({
localStorage: new Backbone.LocalStorage("ExampleModel"),
//Set up default values
defaults: {
"user_name" : "awesome name",
"field 2" : "awesome field"
}
});
}
);
这就是我所说的(使用 Marionette 的区域):
var exModel = new APP.Models.ExampleModel({
"user_name" : "name!",
"field2" : "field!"
});
main_app_layout.header.show(new APP.Views.ExampleView({model: exModel}));
就要求而言,页面正在加载,但我不认为它在做任何事情。任何人都可以帮忙吗?