0
我需要保留从模型实例返回的数据中的原始值。似乎应该有一种从模型中返回未修改数据的方法,但我无法在任何地方找到它。我尝试使用backup.js,但这只适用于静态字符串属性。Javascript MVC - 如何保留初始值
$.Model('My.Example.Models.Thing',
/* @Static */
{
},
/* @Prototype */
{
getMyStuff : function(args) {
$.ajax({
url : '/path/to/my/service,
type : 'get',
contentType : 'application/json',
dataType : 'json',
success : args.success,
error : args.error,
cache : false
});
}
...
init: {
env = this;
}
show: function(){
thing = new My.Example.Models.Thing();
thing.getMyStuff({
params:params,
success: function(data){
// How do you store the original data for later,
// Without it getting updated when data is modified?
thing.myStuff = data;
env.options.thing = thing;
env.processMyStuff(thing);
},
error: function(){
console.log('error');
}
});
},
男人,我浪费了很多时间在这一点。非常感谢! – neridaj 2014-10-01 01:30:09