ここで何が問題なのかわかりませんが、http://rniemeyer.github.com/knockout-kendo/web/DatePicker.html の DatePicker を使用しており、アイテムを配列に送り返すと、フィールドは更新されません。以下のテストでわかるように、選択した日付は、アイテムを返送するときに更新されません. どんな助けでも大歓迎です。ありがとうございました
デモテスト http://s7.postimage.org/68n30bd6z/knockoutjs_knockout_kendo.gif
jsFiddle http://jsfiddle.net/DiegoVieira/epqUb/4/
JS
var data =
[
{
"name": "Diego",
"birthday": "01/01/1984"
},
{
"name": "Franciele",
"birthday": "01/05/1983"
}
];
var person = function() {
this.id = ko.observable(0);
this.name = ko.observable();
this.birthday = ko.observable();
}
function viewModel() {
var self = this;
self.people = ko.observableArray(data);
self.personData = ko.observable(new person());
self.selectedPerson = ko.observable();
self.addPerson = function() {
var item = ko.toJS(new person());
item.id = getRandomNumber();
self.people.push(item);
self.selectedPerson(item);
}
self.editPerson = function(item)
{
self.selectedPerson(item);
}
self.savePerson = function(item)
{
var index = self.people.indexOf(item);
self.people.remove(item);
self.people.splice(index, 0, item);
self.selectedPerson(null);
}
self.deletePerson = function(item)
{
var index = self.people.indexOf(item);
self.people.remove(item);
}
}
ko.applyBindings(new viewModel());
function getRandomNumber(min, max) {
if (typeof min === 'undefined')
min = 10000000;
if (typeof max === 'undefined')
max = 99999999;
return min + Math.floor(Math.random() * (max - min + 1));
}
HTML
<div data-bind="with: $root.selectedPerson">
<table border="1" cellpadding="1" cellspacing="1">
<tr>
<td>Name:</td>
<td><input data-bind="value: name" /></td>
</tr>
<tr>
<td>Birthday:</td>
<td><input data-bind="kendoDatePicker: birthday" /></td>
</tr>
<tr>
<td colspan="2"><button data-bind="click: $root.savePerson">Save</button></td>
</tr>
</table>
</div>
<button data-bind="click: $root.addPerson">Add Person</button>
<ul data-bind="foreach: $root.people">
<li><span data-bind="html: name"></span> (<span data-bind="html: birthday"></span>) <button data-bind="click: $root.editPerson">Edit</button> <button data-bind="click: $root.deletePerson">Delete</button></li>
</ul>