0

I'm trying to add datepicker to my rails 3.2.8 application.

Since it is rails 3+, I didn't add anything to the application.html.erb.

My application.js is the following:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .

$(function(){
    $("#transaction_deadline").datepicker();
});

And in views/transactions/_form.html.erb

I have:

<div class="field">
    <%= f.label :deadline %><br />
    <%= f.text_field :deadline %>
  </div>

But still, datepicker doesn't work and gives:

TypeError: Object [object Object] has no method 'datepicker'

error

That would be great if you can help me.

Thanks,

4

2 Answers 2

3

Maybe this gem can help you => https://github.com/joliss/jquery-ui-rails

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

Comments

0

According to this Railscast , you should add the datepicker component explicitly both in your application.js and application.css .

In application.js:

//= require jquery.ui.datepicker

and in application.css:

*= require jquery.ui.datepicker

Comments

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.