Changing the date format in (aurelia-) jquery datepicker

I’ve downloaded the project from here https://github.com/gitKearney/aurelia-jquery-datepicker. Now, since I’m in a non US date “zone” I would like to change the date format as well as the names of the months and weeks. According to SO and the jquery doc this can be done when one issues the following call ("#datepicker").datepicker();, e.g. ("#datepicker").datepicker({dateFormat: “dd.mm.yy”);. However, after this call the format is still mm/dd/yy. The only place I’ve managed to change the format is in the datepicker.jsattach function, but only after the onevent handler is registered. If I try to set the dateformat before registering said event handler, nothing happens. In the attach function I set the date format like this: $(this.element).datepicker(“option”, “dateFormat”, “dd.mm.yy”);This kind of works, i.e. any initial value set for the date picker is cleared after the format is set, but the format is successfully set.

1 Like

It’s a little hard to decipher exactly what’s going on from the information you’re giving (a repro or a more complete/structured code sample would help a lot), but one thing does come to mind.

You should wrap your initializer code in attached() in a queueMicroTask() call. This ensures that everything else is done before you initialize your datepicker. Regardless of whether that solves the problem, this is a good idea when working with 3rd-party plugins.

1 Like