nazar-pc / PickMeUp

Really simple, powerful, customizable and lightweight standalone datepicker
BSD Zero Clause License
616 stars 191 forks source link

Dynamically format change #191

Closed santuparashetti closed 6 years ago

santuparashetti commented 6 years ago

Not able to change date format after its initialization dynamically. But I can set format while init and its working fine.

my code is like this:

const value = 'd-m-Y' (this value comes from user selection) const comp =$(parentDiv).find('input#pickmeupDate') pickmeup(comp[0], { format: value })

Am I missing anything or is there any other syntax?

nazar-pc commented 6 years ago

There is no support for changing anything after initialization. If you need something like this you'd better destroy the instance and initialize it once again. Alternatively, you can try to modify internal state, but there is no guarantee it'll work in next versions of the library and you might encounter parsing or other issues with existing dates, so be extra careful.

Much better idea depending on use case would be to listen to change event and format date as you like manually.

santuparashetti commented 6 years ago

Thanks @nazar-pc, I think as you suggested in the first option, will destroy the instance and initialize it again is the best solution for my use-case. 👍