0

i emplemented a ui:datepicker lightning component and the select event is not fired when i select a date but only on firefox, chrome run correctly my code.

I've put a console.log in my controller method but nothing return.

I think the select event is not managed in the same way in Firefox & Chrome, but i don't fine solution so, if someone know how to fix that, i'll take it.

Component

<ui:inputDate label="" aura:id="changeWeek" displayDatePicker="true" 
select={!c.changeWeek}" value="{!v.changeWeek}" />

Controller

changeWeek : function(component, event, helper) {
    helper.getFirstDayofWeek(component);
    helper.getShiftList(component);
}

Helper

getFirstDayofWeek: function(component) {
    var daySelected = new Date(component.get('v.changeWeek'));
    var day = daySelected.getDay(), diff = daySelected.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday
    component.set("v.currentDate",new Date(daySelected.setDate(diff)));
}
2

Two potential problems:

1) You are using the Select event to fire the controller. Try using the change event.

2) If that doesn't work, and I have found that it doesn't always work on the ui:inputDate fields, you can try setting up a handler:

<aura:handler name="change" value="{!v.nchangeWeek}" action="{!c.changeWeek}"/>
  • as of today change works just fine in winter17 orgs. seems like ui:inputDate has been significantly improved, format works now as well. it did not work few months ago. There are still some bugs, but in general it is doing better. – Pavlonator Nov 8 '16 at 18:38
  • thaks for your help i was thinking it doesn't work but it's just because you add a n before changeweek in the value attribute, now it work, – Thomas Nov 9 '16 at 14:55
0

the attribute to specify event hadnler for changes is "change". Selection of the day in datepicker will trigger "change".

<ui:inputDate label="" aura:id="changeWeek" displayDatePicker="true" change="{!c.changeWeek}" value="{!v.changeWeek}" />

the "select" event is for the text selection. so when you enter some text, then select few letters out of it - this event will happen. I guess this even is one out of many exposedvia API ti give you opportunity to select the month and then use arrows up/down to change it or change just the portion of the input.

here is the doc

the alternative way to listen for the change is to setup the change listener on attribute directly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.