Act*_*Owl 7 jquery-ui datepicker
$('.selector').datepicker({
onChangeMonthYear: function(year, month, inst) { ... }
});
Run Code Online (Sandbox Code Playgroud)
如何使用onChangeMonthYear的'inst'参数自动选择该月的第一天?
我目前正在使用下面的代码,但我觉得我应该能够以更直接的方式使用'inst'变量.
$(".datepicker" ).datepicker({
changeMonth: true,
changeYear: true,
maxDate:0,
onChangeMonthYear: function(year, month, inst){
// set date to 1st on year or month change
// this seems bit janky, but works
$('#' + inst.id).datepicker( "setDate", month + '/1/' + year );
// Can't I use the instatnce to set the date?
// $(inst).datepicker( "setDate", month + '/1/' + year ); // fails
// inst.datepicker( "setDate", month + '/1/' + year ); // fails
// inst.selectedDay = 1; // fails
// inst.currentDay = 1; // fails
}
});
Run Code Online (Sandbox Code Playgroud)
如果您没有特别的理由想要使用inst,您可以随时使用this:
onChangeMonthYear: function(year, month, inst){
$(this).datepicker( "setDate", month + '/1/' + year );
}
Run Code Online (Sandbox Code Playgroud)
看到它在行动:http://jsfiddle.net/william/sD8rL/2/.
| 归档时间: |
|
| 查看次数: |
18197 次 |
| 最近记录: |