Jack
Jack

Reputation: 3878

jQuery with Rails issue - datepicker()

I have a rails application and I want to add the jQuery datepicker, to show when the user selects a field in a form.

The field is built using the following code:

<%= f.text_field :collection_date_time %>

Resulting in:

<input class="input-medium" id="pick_collection_date_time" name="pick[collection_date_time]" size="30" type="text" />

I have added the following to my pick.js.coffee file, but when I select the field, nothing happens.

$ -> $("#pick_collection_date_time").datepicker()

For info, I'm also using the twitter bootstrap framework (and the associated js).

Any ideas why this isn't working?

Upvotes: 1

Views: 432

Answers (1)

Jakub Oboza
Jakub Oboza

Reputation: 5421

First thing to do in this case is open firbug or chrome inspector and check if he can find the file. Next check development.log if you see any problems with assets. Maybe you did a simple typo somewhere :)

Probably you need to go to app/assets/javascripts/application.js and check if you have something like "//= require_tree ." if not add require for this file or you will have to go to config/environments/<env>.rb and add it to line config.assets.precompile += %w( <name>.js ) so he will precompile with rest.

Upvotes: 1

Related Questions