Couldn't get jquery datepicker onshow function triggered
Using: jquery-1.4.4, jquery-ui-1.7.2
Problem: go through several sections, every section has dateFrom and dateTo. I need to prepopulate minDate of dateTo with currently selected date of dateFrom the right place is dateTo.onShow
Symptoms: setting the break point inside onShow function, clicking datepicker dateTo, not stopped at bp.
here is the code:
$(function() {
$('input[name^="section"]').each(function(i){
var sectionId = $(this).attr('sectionId');
var date2 = "#date2";
date2 = date2.concat(sectionId);
if ($(this).attr('checked')) {
$(date2).datepicker().datepicker('enable');
} else {
$(date2).datepicker().datepicker('disable');
}
$(date2).datepicker({
onShow: function(picker, inst) {
var sectionId = $(picker).attr('sectionId');
var date1 = "#date1";
date1 = date1.concat(sectionId);
var dateMin = $(date1).val();
picker.datepicker('minDate', dateMin);
}
});
});
});
开发者_JS百科
Thanks, VB
Answer: Here is simple fix:
$(function() {
$('input[name^="section"]').each(function(i){
var sectionId = $(this).attr('sectionId');
var date2 = "#date2";
date2 = date2.concat(posterId);
$(date2).datepicker('option', {
beforeShow: processUnpostMinDate
});
});
});
function processUnpostMinDate(picker) {
var posterId = $(picker).attr('sectionId');
var date1 = "#date1";
date1 = date1.concat(sectionId);
return {
minDate: $(date1).datepicker("getDate")
};
}
Regards,
VB
I believe you want beforeShow
. I don't see an onShow
in the documentation.
精彩评论