I needed a datepicker on a form, and in this particular application I’m avoiding writing any javascript to force myself to learn more about ClojureScript. So I set out to learn how to control a JQueryUI datepicker component from ClojureScript.

First, you’ll need to have jQuery and jQuery UI included in your page. I was using Bootstrap for my UI, and the datepicker’s default style wasn’t an option, so you may want to include CSS on your page to style it more appropriately. The CSS used in the jQuery UI demo is available here: http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css.

I used jayq to interact with jQuery in my cljs code. Make certain that you assign the class “datepicker” to all inputs you want to have this feature.

Using the example code above, you’ll need to make sure that myapp.datepick.init(); gets called from your page. You can do this by including <script>myapp.datepick.init();</script> in your page source.