Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9095039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:29:58+00:00 2026-06-16T23:29:58+00:00

I have rails 3.2.1 and to test JQuery UI, i want display a DatePicker.

  • 0

I have rails 3.2.1 and to test JQuery UI, i want display a DatePicker. So, in the “new.hmtl.erb” page i’ve put the following tag:

<p>Date: <input type="text" id="datepicker" /></p>

In the project.js.coffee (the “new” view page is rendered by the project controller) i’ve write:

$( "#datepicker" ).datepicker();

Why the DatePicker doensn’t show up?

In the source code of new page i’ve:

<script src="/assets/projects.js?body=1" type="text/javascript"></script>

that contains:

(function() {
  $("#datepicker").datepicker();
 }).call(this);

I must include some gems? In the application.js i have:

//= require jquery
//= require jquery_ujs
//= require_tree .

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:29:59+00:00Added an answer on June 16, 2026 at 11:29 pm

    Part of the code that will initialize your UI object goes to the page in you case new.html.erb. You add it on bottom as:

    <script>
      $(document).ready(function() {
        $( "#datepicker" ).datepicker();
      });
    </script>
    

    This means when page is loaded it will initialize your input object. In case you need this part of the code to be available trough many pages you add this code in application.html.erb layout. More about layouts you can reads on Rails Guide pages.

    EDIT

    For educational purposes here are additional comments:
    If you want to put code in application.js you can do following:

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

    and then do

    <script>
      $(document).ready(function() {
        setDatePicker();
      });
    </script>
    

    If you want code that will execute when application.js is loaded you just put it there without wrapping it in function (not advised). It will execute when application.js is loaded but it will not work since it can trigger (and probably will) before you DOM is loaded. So always use jquery’s .ready.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails 3.0.7 application. In the functional test I have following code.
In my Rails controller I have the line send_file(#{Rails.root}/test/image.png) I'd like my web page
I have successfully installed jquery-rails in my rails 3 test app. I already had
I could have sworn there was a way to see Rails test output in
I have a Rails controller action to test. In that action, a method User.can?
Trying to get my server to serve my rails apps. I have a test
I am relatively new to rails and have been working my way through the
I'm creating a Ruby (not Rails) script and I have to test using standard
I have an Rails 3 App, here i have a unit test in test/unit/test.rb
In my Rails 3.1 application I have a Jquery dialog that pops up when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.