JQueryUI Update Date After Initialization

On the site, I have the default datapicker set, initialized globally for all inputs with the input-date class.

 $('body').on('focus', '.input-date', function () { $(this).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dmyy' }); }); 

But sometimes I need to add some other options, for example. minDate for a specific item. I have already tried setting this parameter and updating it, but to no avail.

 var dateField = $('#date'); dateField.datepicker('option', 'minDate', new Date()); dateField.datepicker('refresh'); 

So, for now, only the way I managed to change it does it destroy it and create a new one.

 var dateField = $('#date'); dateField.datepicker('destroy'); dateField.datepicker(customOptions); 

Is there a better way to do this?

+4
source share

Source: https://habr.com/ru/post/1500336/


All Articles