我有2個日期選擇器,其中包含按鈕窗格內的複選框。我想根據此框是否被選中來更改日期選擇器。除了日期選擇器的實際改變之外,一切似乎都在工作。我試圖完成的是:如果複選框被選中,日期選擇器將顯示星期數和星期一的第一天。如果未選中該複選框,它不顯示週數和周的第一天是星期天基於複選框更改日期選擇器
腳本:
$(".datepicker").datepicker({
showOn: 'button',
buttonText: 'Date',
showButtonPanel: true,
showWeek: false,
firstDay: 0,
beforeShow: function (input, inst) {
setTimeout(function() {
var buttonPane = $(input)
.datepicker("widget")
.find(".ui-datepicker-buttonpane");
var html = "";
var html = '<div class="broadcastFilter"><input type="checkbox"><label> Use Broadcast calendar </label></div>';
buttonPane.append(html);
test.DateSelectionDateEventBind();
var optionChecked = $('.broadcastFilter input[type="checkbox"]').is(':checked');
//works fine up until here.
buttonPane.click(function() {
if(optionChecked)
{
$(".datepicker").datepicker('option', 'showWeek', true);
$(".datepicker").datepicker('option', 'firstDay', 1);
}
else
{
$(".datepicker").datepicker('option', 'showWeek', false);
$(".datepicker").datepicker('option', 'firstDay', 0);
}
});
}, 1);
},
onChangeMonthYear: function (input) {
setTimeout(function() {
var buttonPane = $(input)
.datepicker("widget")
.find(".ui-datepicker-buttonpane");
var html = '<div><input type="checkbox"><label> Use Broadcast calendar </label></div>';
buttonPane.append(html);
test.DateSelectionDateEventBind();
}, 1);
}
});
http://jsfiddle.net/dan_vitch/zEper/8/
優秀的答案。非常感謝所有的幫助。 –