标签:style blog color io for ar div cti
不多说直接上代码。自定义绑定代码如下:
1 /* my97datepicker 时间格式‘yyyy-MM-dd HH-mm-ss‘ */ 2 ko.bindingHandlers.datetimes = { 3 init: function (element, valueAccessor, viewModel) { 4 var value = ko.utils.unwrapObservable(valueAccessor()); 5 $(element).attr("class", "Wdate"); 6 $(element).focus(function () { 7 WdatePicker({ 8 isShowClear: false, readOnly: true, dateFmt: ‘yyyy-MM-dd HH:mm:ss‘ 9 }); 10 }); 11 $(element).val(value); 12 }, 13 update: function (element, valueAccessor, viewModel) { 14 var value = ko.utils.unwrapObservable(valueAccessor()); 15 $(element).val(value); 16 $(element).blur(function () { 17 var v = $(element).val(); 18 valueAccessor()(v); 19 }); 20 } 21 };
Html代码如下:
1 <input id="date_times" data-bind="datetimes:forms.dates" data-options="required:true" style="width: 150px;" />
Knockout自定义绑定my97datepicker,布布扣,bubuko.com
标签:style blog color io for ar div cti
原文地址:http://www.cnblogs.com/xiaobojy/p/3928648.html