I'm trying to use the Bootstrap Datepicker on a form I'm creating. I've read through the documentation here: https://github.com/Nerian/bootstrap-datepicker-rails/issues/11 and followed it (or so I thought), but I'm stuck.
Gemfile:
gem 'bootstrap-sass', '2.0.4'
gem 'bootstrap-datepicker-rails'
app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-datepicker
//= require_tree .
app/assets/javascripts/orders.js.coffee (I converted the javascript to CoffeeScript)
$("[data-behaviour~='datepicker']").datepicker(
format: "yyyy-mm-dd"
weekStart: 1
autoclose: true
).on "changeDate", (e) ->
app/stylesheets/application.css.scss
*= require_self
*= require bootstrap-datepicker
*= require_tree .
*/
The form (the relevant part, anyway):
<%= form_for [@user, @order] do |order_form| %>
<%= order_form.label "When would you like us to pick up your stuff?" %>
<%= order_form.text_field :order_date, placeholder: "yyyy-mm-dd", 'data-behaviour' => 'datepicker' %>
<% end %>
When I go into the console, I can call the datepicker() method on an element and manipulate its properties from there. But, for whatever reason, it's not working when the page loads. And there aren't any errors in the console.
(based on what I read here: Twitter bootstrap datepicker is not working in rails, I tried the require_self thing and putting the javascript in the application.js file, too. It didn't work and I didn't like the idea of having javascript in the application.js file anyway...)