Datepicker reset function

I am trying to refresh datepickers min and max value. I’ve tryed to call with refresh function after I set new min and max values, but datepickers calendar loses event handler and after picking new date input field doesn’t change.

How to properly refresh min and max value?

Hi @anon30815302,

(assuming you’re talking about AUI development) I’m not exactly sure what the issue is, could you try to describe it in more detail, maybe share a code sample?

Usually, to update the min and max (or any other props for that matter), you just call the initialization code again. This should also not influence any listeners you’ve added with jQuery.

I’ve successfully tested this with the following code from the AUI docs:

<input class="aui-date-picker" id="demo-range-1" type="date" max="2012-01-25" min="2011-12-25" />
AJS.$(document).ready(function() {

    AJS.$('#demo-range-1').change(() => console.log('change!'));
    AJS.$('#demo-range-1').datePicker({'overrideBrowserDefault': true});
});
// ...
// then change max in HTML and call 
AJS.$('#demo-range-1').datePicker({'overrideBrowserDefault': true});
// again.

Hi tobitheo, thanks you for response.

I am talking about calendar dialog event, not date picker input tag event. I have two datepicker formDate, toDate. When I select fromDate I want to reset min date on second DP.

Now I am reseting this in onSelect event of frst DP (fromDate).

At the moment i set new min date in onSelect function
document.getElementById(formDateID).setAttribute("min", document.getElementById(toDateID).value);

And then I call AJS.$(’#toDate’).datePicker …

Result is ok, but this code produces multiple calendar dialogs (at least two) and sometime you need to click two times that you close calendar dialog. And if you are clicking on toDate input field, you can see different dialogs, beacuse selested date is different on each click.

I can get rid of this behaviour by calling datepicker AJS.$(’#toDate’).reset(). Dialog ar ok, but now the date field doesnt change when you select new date in dialog. This is even worse.

I am not sure how to change “min” value properly