2
我確實在本地系統中有一些數據。這是我通過骨幹實施的。作爲疑問是否可以同步我的功能與本地數據添加或刪除?是否有可能在離線狀態下同步工作
還是骨幹只能在服務器響應?如果它甚至在本地主機上工作,我如何同步我在這裏做出的本地請求?
任何人看這個rquest,請不要介意我,我是非常新的背後和緊張的位置,使一個項目。
代碼。我寫:
(function($){
var list = {};
list.model = Backbone.Model.extend({
defaults:{
name:'need the name'
}
});
list.collect = Backbone.Collection.extend({
model:list.model,
url : 'data/names.json',
initialize:function(){
this.fetch(); // how can i sync?
}
});
list.view = Backbone.View.extend({
initialize:function(){
this.collection = new list.collect();
this.collection.on("reset", this.render, this);
},
render:function(){
_.each(this.collection.models, function(data){
console.log(data.get('name'));
})
}
});
var newView = new list.view();
})(jQuery)
非常感謝你。你知道任何教程是證明這一點嗎? – 3gwebtrain
不幸的是,我不知道它的任何教程,但在backbone.offline git-hub頁面上有兩個例子的鏈接,saveidea和dreamy(Open Source)。另外backbone.offline基於部分基於[骨幹本地存儲](https://github.com/jeromegn/Backbone.localStorage)適配器,所以也許看着這將幫助你。 – Jack
也檢查https://github.com/nilbus/Backbone.dualStorage – TuteC