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

  • Home
  • SEARCH
  • 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 8836445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:29:47+00:00 2026-06-14T09:29:47+00:00

I have a JQueryUI datepicker defined as follows: $(function() { $(.visit_date).datepicker({ changeMonth: true, changeYear:

  • 0

I have a JQueryUI datepicker defined as follows:

$(function() {
  $(".visit_date").datepicker({
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    dateFormat: "yy-mm-dd"
  });
});

The view code which produces the Datepicker text box is

<td><%= f.label :visit_date %></td>
<td><%= text_field_tag :visit_date, @visit.visit_date, :class => 'visit_date'

and the view, when rendered, is generated between tags like this:

<div id="action_window">
   (rendered HTML to be acted on by user) 
</div>

Why doesn’t the Javascript selector “.visit_date” hook up with this view? In other words, without the “action_window” tags it used to work. My thinking was that “.visit_date” would match anything with class “visit_date”.

======================
UPDATE on 11/7/2012. Javascript code:

$(function() {
  $("#visit_date").datepicker({
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    dateFormat: "yy-mm-dd"
});   

});

The original place where the user pushes the button:

<%= link_to "Add Visit", new_client_visit_path(@client), :remote => true, :class => "btn btn-primary btn-large" %>

In VisitsController:

respond_to do |format|
  format.html
  format.js { }
end

In views/visits/new.js.erb:

$('#action_window').html('<%= escape_javascript render(:partial => "new") %>');
$('#action_window').show;

(#action_window is a div in the Client index view)

In views/visits/_new.html.erb:

<%= render "form" %>
<%= link_to "Cancel", @client, :class => "btn btn-primary btn-large" %>

In views/visits/_form.html.erb:

%= form_for [@client, @visit] do |f| %>
<td><%= text_field_tag :visit_date, @visit.visit_date, :class => 'visit_date' %>

I have not been able to get the Datepicker to work, presumably because the HTML creating the “New Visit” view is rendered, and somehow JQueryUI can’t associate it without that “hasDatepicker” thing added to the class.

  • 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-14T09:29:48+00:00Added an answer on June 14, 2026 at 9:29 am

    When you dynamically add an element you want to be a date picker, and the original static page contains say this jquery to make some elements datepicker:

    $(‘.visit_date’).datepicker();

    When the new element get’s added, and it has class=’visit_date’, it won’t be a datepicker UNLESS you call jquery’s datapicker on it.

    So if you are using new.js.erb to add a dynamic datepicker element, you could do this:

    $('#action_window').html('<%= escape_javascript render(:partial => "new") %>');
    $('.visit_date').datepicker();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQueryUI datepicker, which was created with dateFormat: 'dd/mm/yy'. If I use
I have problems with this datepicker http://jqueryui.com/demos/datepicker/ <script> $(function() { $( #datepicker1 ).datepicker({ dateFormat:
I have been testing and playing around with jquery date picker below. http://jqueryui.com/demos/datepicker/ on
I'm using the jQuery datepicker from jqueryui.com and I have a problem changing the
I have a jqueryui datepicker associated with a input text. When i make the
I have jquery ui datepicker inside the slider which is working on mouseover/leave and
I have two jQueryUI datepickers on my page. They're initialised as below: jQuery(#departureDate).datepicker({ beforeShow:
I am using the datepicker in jQueryUI and need to have the inline datepicker.
My client wants a program which will use a datepicker which will have certain
In an ASP.NET project, I'm looking for a way to have a jQueryUI datepicker

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.