i trying push multiple data (firstname , lastname), along when compute firstname , lastname , try push data in same array thrown error. below code. viewmodel: var viewmodel = function () { var self = this; self.gameofthrones = ko.observablearray ([ {firstname: 'jon', lastname: 'snow'}, {firstname: 'robb', lastname: 'stark'} ]); self.firstname = ko.observable(''); self.lastname = ko.observable(''); (var i=0; i<self.gameofthrones().length; i++) { self.gameofthrones()[i].fullname = ko.computed (function () { return self.gameofthrones()[i].firstname+" "+self.gameofthrones()[i].lastname; }) }; $('#classic').click( function() { self.gameofthrones.push( {firstname: $('#fn').val(), lastname: $('#pr').val()} ); }); } ko.applybindings(new viewmodel()); html view: <form class="" action="index.html" method="post"...
Comments
Post a Comment