jquery - How can i reset list viewModel -
i have list of model same knockoutjs live example: http://jsfiddle.net/rniemeyer/7rdc3/
main:
var viewmodel = new giftmodel([ { name: "tall hat", price: "39.95"}, { name: "long cloak", price: "120.00"} ]); ko.applybindings(viewmodel);
how can reset object viewmodel null or new giftmodel([])
button click event (not use knock out event)
, want whenever click button, grid empty gift. example :
$( "#button" ).click(function() { clearknockoutviewmodel(); });
---> viewmodel empty , html clear.
this right way.
$( "#button" ).click(function() { clearknockoutviewmodel(); }); function clearknockoutviewmodel(){ var element = $('#elementid')[0]; ko.cleannode(element); ko.applybindings(viewmodel, element); }
you loose viewmodel logic if empty it.
Comments
Post a Comment