javascript - Knockout view model serialize to db and retrieve -
i have web form use knockout , have implement new feature save form draft db , later load again modify or submit.
is there feature on knockout framework serialize viewmodel other form(like json) save db. later load , populate view easily.
i know can save viewmodel json db , later can load , fill each property on view model below. im looking feature serialize , later populate whole viewmodel @ once using it.i have lot of properties , don't want fill each property writing code line below.
var somejson = /* fetched saved viewmodel json */; var parsed = json.parse(somejson); // update view model properties viewmodel.firstname(parsed.firstname); viewmodel.pets(parsed.pets);
use mapping plugin , replace code one:
var somejson = /* fetched saved viewmodel json */; var parsed = json.parse(somejson); // update view model properties viewmodel = ko.mapping.fromjs(data);
Comments
Post a Comment