cloneObj = function(obj){ if(ko.isWriteableObservable(obj)) return ko.observable(obj()); //this is the trick if(obj === null || typeof obj !== 'object') return obj; var temp = obj.constructor(); // give temp the original obj's constructor for (var key in obj) { temp[key] = cloneObj(obj[key]); } return temp; };(http://stackoverflow.com/questions/14055279/javascript-clone-object-with-knockoutjs-observable-properties?rq=1)
Không có nhận xét nào:
Đăng nhận xét