1
淘汰賽日期選擇器數據綁定可以在這裏找到: jQuery UI datepicker change event not caught by KnockoutJS淘汰賽與jQuery UI的日期選擇器,MM/YY僅
爲了隱藏日期(這是觸發日期選擇器的輸出的唯一的事情),我這樣做對於sans淘汰賽的解決方案:
$(".monthPicker").focus(function() {
$(".ui-datepicker-calendar").hide();
});
$(".monthPicker").datepicker({
dateFormat: 'MM yy,
changeMonth: true,
changeYear: true,
showButtonPanel: true,
onClose: function(dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).val($.datepicker.formatDate('MM yy', new Date(year, month, 1)));
}
});
這是有效的。
但是我怎樣才能使用knockout的數據綁定工作呢?
檢查onClose中的雙引號並將它們更改爲單引號。你可能會使用'data-bind =「.....」東西「.....」得到錯誤'' – BartekR
這是解析,但不綁定到selectedMonthDate,仍然。 –
發佈我正在使用的確切代碼,並保持最新狀態。我試圖找出這個結果,然後結束綁定。如果我毆打別人,我會發布我的答案。 –