Hi all,
I’m trying to work out how to get started using some jQuery in my rails
app.
rails -v = 3.2.2
ruby -v = 1.9.3-p194
I’m only sporadically a web-developer, and still quite inexperienced
with jQuery especially, so I may be making an obvious mistake.
Essentially, I’ve done very little after creating a new app, I’ve learnt
that jQuery is included by default with the gem ‘jquery-rails’, ‘2.0.0’.
In my application.js (app/assets/javascripts) I’ve added the line //=
require jquery-ui
I now want to have a datepicker in one of my forms, looking at the
jQueryUI website (Datepicker | jQuery UI) I can see that
the class of the text-field has to be “hasDatepicker”, and the id
“datepicker”
I’ve done this in my view like this
<%= f.text_field :game_start_time, :class => :hasDatepicker, :id =>
:datepicker %>
and also to test like this
however when I click on the text-field nothing happens, no date picker
appears.
Is there some massively obvious step I’m missing here?
I’ve looked in the developer tools at the ‘scripts’ part, and found that
jQuery-ui seems to be loading with the page, I can even search and find
the datepicker fucntion there.
Is there some function I need to add in to say when the user clicks on
this text field, - show the date picker?
Thanks in advance