jquery - Why is my knockout.js value not being saved? -


update: added a jsfiddle of problem. rewrote question ideas have changed.

i have page using knockout.js layout. have working on page in application, can't 1 work. model consists of parent record , it's child records. problem when try make copy of previous row make easier user add many similar records. when type values in department, project, job, , comment fields, values blank in model when go copy fields, remain blank.=. ideas? guessing missing stupid.

 function dayviewmodel(day) {      var self = this;       self.date = day.date;      self.time = day.time;      self.hours = ko.observable(day.hours);      self.timesheetcode = ko.observable(day.timesheetcode);      self.department = ko.observable(day.department);      self.project = ko.observable(day.project);      self.job = ko.observable(day.job);      self.comments = ko.observable(day.comments);      self.jobisrequired = ko.observable((day.jobisrequired == undefined) ? false : day.jobisrequired);  }   function requestviewmodel() {      var self = this;       self.daysrequested = ko.observablearray([new dayviewmodel({          date: new date().tostring("mm/dd/yyyy"),          time: "08:00 am",          hours: 1,          timesheetcode: "",          department: 0,          project: 0,          job: 0,          comments: ""      })]);      self.timesheetcodes // gets data external data source       // add day copying previous day.      self.addday = function () {          var array = self.daysrequested();          var previousday = array[array.length - 1];          previousday.date = date.parse(previousday.date).adddays(1).tostring("mm/dd/yyyy");           var test = ko.utils.unwrapobservable(previousday.department);           var newday = new dayviewmodel({              date: previousday.date.tostring("mm/dd/yyyy"),              time: previousday.time,              hours: ko.utils.unwrapobservable(previousday.hours),              department: ko.utils.unwrapobservable(previousday.department),              project: ko.utils.unwrapobservable(previousday.project),              job: ko.utils.unwrapobservable(previousday.job),              comments: ko.utils.unwrapobservable(previousday.comments),              timesheetcode: ko.utils.unwrapobservable(previousday.timesheetcode)          });          self.daysrequested.push(newday);      }  } 

you're using text binding on of fields when need value binding. example, department should

<input type="text" class="input-small department-entry" max="5" data-bind="value: department, uniquename: true" /> 

Comments