calendar set minDate and maxDate dynamically

Get help with using Metro 4 components
Post Reply
drodriguez
Posts: 44
Joined: Wed Apr 11, 2018 7:32 pm
Status: Offline

calendar set minDate and maxDate dynamically

Post by drodriguez » Fri Jul 20, 2018 6:08 pm

How can i change minDate and maxDate dynamically by javascript?

HTML:
<input id="calendar" type="text" data-role="calendarpicker" data-validate="required" data-size="200px" data-show-header="false" data-show-footer="false" data-format="%d/%m/%Y" data-years-before="0">

I tried:

$('#calendar').data('calendarpicker').setMinDate(2018/07/21');
or
$('#calendar').data('calendarpicker').changeAttribute('data-min-date', '2018/07/21') ;
but nothing happend

changeAttribute of calendarpicker(line 5966 of v4.2.14) has:

changeAttribute: function(attributeName){
switch (attributeName) {
case "value": this.changeValue(); break;
case 'disabled': this.toggleState(); break;
case 'data-locale': this.changeAttrLocale(); break;
case 'data-special': this.changeAttrSpecial(); break;
case 'data-exclude': this.changeAttrExclude(); break;
}
}

changeAttribute must be a "key" , "value" parameters?
example:

changeAttribute: function(attributeName, value){
switch (attributeName) {
.....
case 'data-min-date': this.setMinDate(value); break;
case 'data-max-date': this.setMaxDate(value); break;
}

Thanks

User avatar
olton
Site Admin
Posts: 133
Joined: Mon Apr 09, 2018 6:19 pm
Location: Kiev, Ukraine
Status: Offline

Post by olton » Fri Jul 20, 2018 6:32 pm

in the current version, you can set dynamically these attributes only for the calendar component.

User avatar
olton
Site Admin
Posts: 133
Joined: Mon Apr 09, 2018 6:19 pm
Location: Kiev, Ukraine
Status: Offline

Post by olton » Fri Jul 20, 2018 6:43 pm

in 4.2.15:
+ [x] Calendar picker: add observing attributes `data-min-date`, `data-max-date`

wait for the new version. Release on 07/25

Post Reply