Open mulgurul opened 11 years ago
I have the same problem and to me it seems that there's now way around. You can give something like: selectableYears: [2012, 2013, 2015] and it will work.
selectableYears: [1980, 2013, 2015] however will not work!!!
Unfortunately there is now word about this important "feature" on the plugin page, cost me quite some time :-/
I have the same issue and even after trying all the examples ... the only way to select older dates was to set todayDate ... but that also limits the selection to +/- years from todayDate. I want to let people set their birthDate ... and for that the range must be huge like: selectableDateRange: [ { from: new Date(1904, 8, 1), to: new Date(1996, 12, 31) }, ], selectableDates: [ { date: new Date(1904, 1, 1) }, { date: new Date(1996, 12, 31) } ],
No settings seem to have any effect :(
Hi,
I had a similar problem, but the solution is not very difficult. Open glDatePicker.js and make the following changes:
Find:
// Helper function to build selectable list
var getSelectableList = function(min, max, userList) {
// Build a default list using min/max
var resultList = [];
for(var i = min; i <= max; i++) { resultList.push(i); }
// If user provided a collection, sanitize list by ensuring it's within range and unique
if(userList) {
var newList = [];
$.each(userList, function(i, v) {
if(v >= min && v <= max && newList._indexOf(v) < 0) {
newList.push(v);
}
});
resultList = newList.length ? newList : resultList;
};
// Sort the values before returning it
resultList.sort();
return resultList;
};
Replace:
// Helper function to build selectable list
var getSelectableList = function(min, max, userList, noLimits) {
// Build a default list using min/max
var resultList = [];
for(var i = min; i <= max; i++) { resultList.push(i); }
// If user provided a collection, sanitize list by ensuring it's within range and unique
if(userList) {
var newList = [];
$.each(userList, function(i, v) {
if(((v >= min && v <= max) || noLimits) && newList._indexOf(v) < 0) {
newList.push(v);
}
});
resultList = newList.length ? newList : resultList;
};
// Sort the values before returning it
resultList.sort();
return resultList;
};
Find:
var selectableYears = getSelectableList(todayVal.year - 5, todayVal.year + 5, options.selectableYears);
Replace:
var selectableYears = getSelectableList(todayVal.year - 5, todayVal.year + 5, options.selectableYears, true);
That's it.
Thanks for the fix @hayatbiralem Works great as long as you have set the selectableYears option set.
That's very kind of you. I'm glad to be helpful.
does not work any more this fix it seems :( i also need this for a birthday field...
this does not work any more currently, or i am doing something wrong .. somebody else facing this when using for a birthday field? driving me nuts!
I may be blind, but I cant figure out how to allow more than the default +-5 years range. I need to let users select their birthday. can someone provide an example for this?
Best regards
Peter