calendarpciker data-on-change fire twice

General issues related to the use of Metro 4
Post Reply
drodriguez
Posts: 44
Joined: Wed Apr 11, 2018 7:32 pm
Status: Offline

calendarpciker data-on-change fire twice

Post by drodriguez » Fri Jul 20, 2018 11:28 pm

html calendarpicker:

<input id="date" 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" data-min-date="2018/07/21" data-on-change="dateChange()">


custom dateChange() event fire twice

onDayClick: function(sel, day, el){
var date = new Date(sel[0]);
that.value = date.format("%Y/%m/%d");
that.value_date = date;
element.val(date.format(o.format, o.locale));
element.trigger("change"); //first custom event dateChange() fire
cal.removeClass("open open-up");
cal.hide();
Utils.exec(o.onChange, [that.value, that.value_date, element]); //second custom event dateChange() fire

what i do wrong?

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

Post by olton » Fri Jul 20, 2018 11:37 pm

element.trigger() fire standard input onchange event. Utils.exec fire Metro4 event data-on-change for input.

You can use standard event or Metro4 event for your choice.

drodriguez
Posts: 44
Joined: Wed Apr 11, 2018 7:32 pm
Status: Offline

Post by drodriguez » Fri Jul 20, 2018 11:56 pm

thanks...
the code
onDayClick: function(sel, day, el){
var date = new Date(sel[0]);....


is at https://cdn.metroui.org.ua/v4/js/metro.js line 5791 and i dont know how tell to Metro fire event once.

Post Reply