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?

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

2 Comments

It didn't work, I'm not getting an error but datepicker doesn't appear there. Id of field is also correct
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 (-_-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.