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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:20:52+00:00 2026-05-26T02:20:52+00:00

I like that jQueryUI datepicker is customizable enough to allow for a button to

  • 0

I like that jQueryUI datepicker is customizable enough to allow for a button to trigger showing the datepicker, but, unfortunately, it doesn’t allow you to customize your own markup.

If I have markup like so:

<span>
    <input type="text" class="datepicker" />
</span>
<span>
    <button class="datepicker-trigger">Open</button>
</span>

In order to get it the datepicker to show when clicking the button, I’d have to implement the following code:

$('.datepicker').datepicker({
    showOn:'none'
});
$('.datepicker-trigger').click( function() {
    $('.datepicker').datepicker('show');
});

Here’s a jsFiddle of the above code: http://jsfiddle.net/P9Qmu/

This is all well and good, but what I really want to do is pass the datepicker function an additional argument that specifies an object or selector indicating what element should trigger the showing.

For example, I’d really like to be able to do this:

$('.datepicker').datepicker({
    showOn:'none',
    trigger:'.datepicker-trigger'
});

I know how to extend jQuery to add methods and create plugins, but I’m not sure how (or if it’s possible) to modify the allowed arguments in an existing function.

Does anyone know how I could extend $.datepicker to achieve what I’m looking to do or at least point me in the right direction? Any help would be much appreciated.

  • 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-26T02:20:52+00:00Added an answer on May 26, 2026 at 2:20 am

    How about:

    var __picker = $.fn.datepicker;
    
    $.fn.datepicker = function(options) {
        __picker.apply(this, [options]);
        var $self = this;
    
        if (options && options.trigger) {
            $(options.trigger).bind("click", function () {
                $self.datepicker("show");
            });
        }
    }
    

    Usage:

    $("#date").datepicker({
        trigger: "#button"
    });
    
    $("#date2").datepicker({
        trigger: "#button2"
    });
    

    Example: http://jsfiddle.net/gduhm/


    Or, less intrusively with your own jQuery plugin:

    $.widget("ui.datepicker2", {
        _init: function() {
            var $el = this.element;
            $el.datepicker(this.options);
    
            if (this.options && this.options.trigger) {
                $(this.options.trigger).bind("click", function () {
                    $el.datepicker("show");
                });
            }
        }
    });
    

    (Similar usage, except use datepicker2 or whatever you name it)

    Example: http://jsfiddle.net/puVap/

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

Sidebar

Related Questions

I am trying to setup two date pickers like this http://jqueryui.com/demos/datepicker/#date-range . But if
Not that I'm doing something like that, but I am kind of interested how
I would like that the Index action doesn't appear in the url. For example,
I've got this answer working but I'd like to extend it: jQuery UI Datepicker
i want to use jquery UI's datepicker to trigger a POST that would then
I'm trying to incorporate jqueryUI's datepicker inside a partialview like this: <% using (Ajax.BeginForm(/EditData,
I'm looking for a jQuery popup calendar (like the jQuery UI Datepicker ) but
I'd like to attach the jQueryUI datepicker control so users can pick their date
I'm working on a site that uses a Jquery UI datepicker to allow users
I like that in PHP I can do the following $myInteger++; $myString += 'more

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.