我从这里http://eonasdan.github.io/bootstrap-datetimepicker/Installing/#knockout使用带有引导程序 DateTimePicker 的淘汰赛 js ,一切正常,但问题在于提交阶段,即当我提交表单时我可以' t 获取 datetimepicker 输入字段的更新值:这是我的工作 HTML:
<div data-bind="foreach: params">
<input class="form-control" type="text" data-bind="attr: { name: label}, value: value, dateTimePicker: 'date_field'" />
<button data-bind="event: { click: addParameters } , attr: { class: btn btn-success', href: 'javascript:void(0)'}">Save Settings</button>
</div>
这是我的视图模型:
function viewModel(data)
{
// date field observable
self.date_field = ko.observable(new Date('2012/12/12'));
// Observable to track the html form
self.params = ko.observableArray();
// when user click by Save Settings button
self.addParameters = function(options)
{
var dataparams = self.params();
console.log(dataparams);
}
}
ko.applyBindings(new viewModel);
谁能指导我做错了什么?谢谢你的提前。