I created some custom datepicker using jQuery datepicker, and it works perfect. There is some scenarios when I need some functionality for onSelect event, and want to overri
As this is not possible, I think out workaround: will pass function as param to custom jQuery function. This is code for creating datepickers:
var onSelectFunction = function(dateValue){
$('#end_date.datepicker').datepicker("option", "minDate", dateValue);
}
options.onSelect = onSelectFunction;
$('#start_date.datepicker, #end_date.datepicker').attachCustomDatepicker(options);
and this is preview of my custom function:
$.fn.attachCustomDatepicker = function(options) {
var defaultOptions = {
someDefaultCustomParamsHere: ,
onSelect: null
}
var onSelectFunction = function(params){ return false; }
if (typeof options == 'object') {
options = $.extend(defaultOptions, options);
} else {
options = defaultOptions;
}
if(!options.onSelect){
options.onSelect = onSelectFunction;
}
$(this).datepicker( "destroy" );
$(this).datepicker({
onSelect: function (dateValue, inst) {
options.onSelect(dateValue);
}
}
}