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 6809449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:05:17+00:00 2026-05-26T20:05:17+00:00

i’m using asual jquery-address, tabs example and want to add datepicker to the Extra

  • 0

i’m using asual jquery-address, tabs example and want to add datepicker to the “Extra” tab.
If i’m just adding

$(document).ready(function() {
    $( "#datepicker" ).datepicker();
});

it wont work. So i found out i have to use .live().
As im using jquery-1.7 .live() has changed to .on().

If i add this code datepicker only works on the second click.

$(document).ready(function() {
  $(document).on('click', '#datepicker', function () {
    $(this).datepicker();
  });
});

I saw in another thread a not recommended way to make it work like this

$(document).ready(function() {
  $(document).on('click', '#datepicker', function () {
    $(this).datepicker().datepicker( "show" );
  });
});

How am i using it correctly? Is there a recommended way to make datepicker work like i want in this example?

I think i need to use .on() because i want to reload the form that’s including #datepicker with a .load() event.

  • 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-05-26T20:05:18+00:00Added an answer on May 26, 2026 at 8:05 pm

    To walk through your three approaches, the first one is failing because your is set up in a way such that #datepicker is not yet defined. You could check this by replacing it with alert($('#datepicker').length) and seeing that it is zero.

    The second approach is taking two clicks because the datepicker is unaware of the first click because it was created after the click occured.

    The third approach works because it forces the datepicker to appear after the first click. That is fine but a little wasteful because after you set up the datepicker, it has its own event listener that will make it appear when the click starts.

    Going back to your first approach, it wasn’t working because #datepicker didn’t exist yet. You could make this work by moving ('#datepicker').datepicker() to after the point in the code where it is created.

    If this is not possible, you can make it so your function only fires on the first click by using the third approach but switching from on to one. This will make it so the first click is your event listener that creates and shows the date picker. After that, your event listener will be removed and only the built-in date picker listener will exist.

    That said, I really hate $(document).on('click', ... because it evaluates every time you click on the page. It captures the event at the document level and then compares every element in the target list to the selector. This is slow and really adds up if you have a lot of them. If you must use a delegated listener, you should move it to the closest parent. For example, if #datepicker always appears in #form1, you could do $('#form1').on('click', ... instead and reduce your processing.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

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.