0

I've this app in ruby on rails framework and have one of a form field of date_select. I wanted to add datepicker of jquery in this date_select field using this link but nothing seems to work for me.

I've jquery-ui version 4.2.1 but still I'm getting error of Couldn't find file 'jquery-ui/datepicker' with type 'application/javascript' in rails

Here's my app\assets\javascripts\application.js-

// some written text-

//= require rails-ujs
//= require turbolinks
//= require_tree .
//= require jquery-ui/datepicker

Here's my app\assets\stylesheets\application.css

/*
*= require_tree .
*= require_self
*= require jquery-ui/datepicker
*/

Here's my form-field in one of the controller view-

<%= form.text_field(:dateneed, id: :order_dateneed, :class=>'form-control mb-1') %>

and finally here's my coffee script of one of the controller-

$(document).on 'turbolinks:load', ->
  $('#order_dateneed').datepicker
    dateFormat: 'yy-mm-dd'

I'm tired since morning of trying all things from degrading version of jquery-ui-rails from 5.0 to 4.2.1 but still there's no datepicker in my text_field of date. Can anyone please help?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

As I see in your link you need to install gem in your Gemfile:

gem 'jquery-ui-rails'

(run bundle after this)

Also write in app/assets/javascripts/application.js:

//= require jquery.ui.datepicker

And in app/assets/stylesheets/application.css:

*= require jquery.ui.datepicker

(you wrote via dash)

mechnicov
  • 12,025
  • 4
  • 33
  • 56
  • It didn't work, I'm not getting an error but datepicker doesn't appear there. Id of field is also correct – Aaditya rathore May 16 '20 at 11:05
  • The most frustrated moment happened with me, I was trying to resolve the issue from last 6-8 hours and finally found that I forgot to add the jquery cdn plugin in my application.html.erb (-_-) – Aaditya rathore May 16 '20 at 11:26