简体   繁体   中英

JQuery UI Datepicker Thai Buddhist Year

I am using jquery-1.11.0 and jquery-ui datepicker to achieve a dropdown datepick on my textfield.

However, for Thailand, there is something call the Buddhist year which adds 543 to our current phyiscal year. How can I achieve this with the jquery datepicker? I have tried the follow sites but due to different jquery version, it seems to have a weird behaviour.

https://code.google.com/p/jquery-ui-datepicker-extension-buddhist-era/

http://www.anassirk.com/articles/1

http://keith-wood.name/calendarsPickerRef.html

What you describe is fairly trivial with leveraging the datepicker's yearSuffix option, which allows you to insert unescaped html. Something like:

In stylesheet:

.ui-datepicker-year { display:none; }

In onChangeMonthYear :

inst.settings.yearSuffix = year + 543;

See jsfiddle here

Disclaimer: At some point someone will probably realize what a terrible idea it is to append unescaped html to your widget's titlebar, and this will become unusable. Should be fine for 1.11.0/1.10.4.

Disclaimer2: I know absolutely nothing about Buddhist years. This simply changes the visible year to year+543 . It handles absolutely no corner cases

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM