# Datepicker is not working

**URL:** <https://discuss.rubyonrails.org/t/datepicker-is-not-working/69334>\
**Category:** rubyonrails-talk\
**Created:** [July 19, 2014, 3:41pm UTC](https://discuss.rubyonrails.org/t/datepicker-is-not-working/69334 "2014-07-19T15:41:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [July 19, 2014, 3:41pm UTC](https://discuss.rubyonrails.org/t/datepicker-is-not-working/69334/1 "2014-07-19T15:41:25Z")

</div>

I am using Ruby 1.9.3 and Rails 3.2.16.

I want to add the datepicker widget to one of my select fields. I have included 'jquery\_datepicker', 'jquery-rails', 'jquery-ui-rails' in Gemfile. I am new for JQuery.

> > The form code like as follow:

\<div class="field"\> &nbsp;&nbsp;&nbsp;&nbsp;\<%= f.label :expense\_on %\>\<br /\> &nbsp;&nbsp;&nbsp;&nbsp;\<%= f.text\_field :expense\_on, :id =\> "datepicker" %\> \</div\>

> > Code for application.js :

//= require jquery //= require jquery-ui //= require jquery\_ujs //= require bootstrap //= require\_tree .

$(function() { &nbsp;&nbsp;$('#datepicker').datepicker({dateFormat: 'yy-mm-dd'}); });

> > code for application.css:

/\* \*= require\_self \*= require jquery-ui \*= require\_tree . \*/

I am not getting any error.

I attached application.html.erb. Please find it.

How could i fix this problem?

Kind regards.

Attachments: [http://www.ruby-forum.com/attachment/9916/application.html.erb](http://www.ruby-forum.com/attachment/9916/application.html.erb)

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [July 20, 2014, 4:43am UTC](https://discuss.rubyonrails.org/t/datepicker-is-not-working/69334/2 "2014-07-20T04:43:23Z")

</div>

I have solved this problem.

---

<div class="post-metadata">

**Author:** ![Colin\_Law](https://avatars.discourse-cdn.com/v4/letter/c/b9e5f3/32.png) [@Colin\_Law](https://discuss.rubyonrails.org/u/Colin_Law)\
**Post date:** [July 20, 2014, 7:34am UTC](https://discuss.rubyonrails.org/t/datepicker-is-not-working/69334/3 "2014-07-20T07:34:26Z")

</div>

Thanks for sharing the solution so that others can learn from it.

Colin

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [July 20, 2014, 4:54pm UTC](https://discuss.rubyonrails.org/t/datepicker-is-not-working/69334/4 "2014-07-20T16:54:05Z")

</div>

I have solved this problem.

I have changed application.html.erb file. I attached updated file of application.html.erb, Please find it.

I have add code in \*\*quantities.js.coffee\*\* like as follow:

jQuery -\> &nbsp;&nbsp;$('.datepicker').datepicker()

Kind regards.

Attachments: [http://www.ruby-forum.com/attachment/9917/application.html.erb](http://www.ruby-forum.com/attachment/9917/application.html.erb)

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [July 20, 2014, 4:56pm UTC](https://discuss.rubyonrails.org/t/datepicker-is-not-working/69334/5 "2014-07-20T16:56:00Z")

</div>

> Thanks for sharing the solution so that others can learn from it.

Thank you for your suggestion. I have shared my solution.

Kind regards.
