Reputation: 17
I am trying to implement datepicker to a rails app , so i have been able to run it in reference with these two links :
http://jakoblaegdsmand.com/blog/2012/05/rails-datetime-picker/ https://github.com/Nerian/bootstrap-datepicker-rails
For some reason it runs just fine when i run it with a scaffold but when i try to run it by building a rails application from scratch by building a model,controller,view respectively its not running,basically nothing happens when i click on the date text field.
This is the following code that i have written.
In the Gemfile
gem 'bootstrap-datepicker-rails'
IN the appplication.css
*= require bootstrap-datepicker
In the application.js
//= require bootstrap-datepicker
In the _form.html.erb
<%= form_for(@category) do |f| %>
<%= f.label :Name %><br/>
<%= f.text_field :name %><br/>
<%= f.label :Description %><br/>
<%= f.text_area :description %><br/>
<%= f.label :EmailID %><br/>
<%= f.text_field :emailid %><br/>
<%= f.label :Date %><br/>
<%= f.text_field :cdate, :class => 'datepicker', 'placeholder'=> "dd-mm-yyyy" %><br/>
<script>
$(function() {
$('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
});
</script>
<% end %>
In Schema.rb
ActiveRecord::Schema.define(version: 20150312163128) do
create_table "categories", force: :cascade do |t|
t.string "name"
t.string "emailid"
t.text "description"
t.date "cdate"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
So kindly tell what i am doing wrong , have been stuck at this since 3 days.
Upvotes: 1
Views: 4442
Reputation: 654
I checked your gihub link. And your sequence is wrong. Jquery and jquery-ui should always be first in sequence.
//= require bootstrap-datepicker
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Try updating this as follows:
//= require jquery
//= require jquery_ujs
//= require bootstrap-datepicker
//= require turbolinks
//= require_tree .
Upvotes: 1