I did some playing around and came up with 2 methods that arent
perfect but get you closer to what you asked for.
The issue is that datepicker really wants to use the onFocus or a
button click for it to be activated.

1. If you don't mind showing your text as a button this is the
simplest method, just use a hidden field:
$("#hiddendate").datepicker({ showButtonPanel:true, showOn:'both',
closeText:'X', buttonText:'Show Calendar'});
<input type="hidden" id="hiddendate">

2. If you REALLY don't want to use a button, you can get away with
using jquery toggle and 2 spans. however, only way to open and close
the calendar is to click on the 1st span.
$("#myspan").click(function() {
           $("#anotherspan").datepicker({ showButtonPanel:true,
showOn:'both', altField: '#actualdate', closeText:'X',
buttonText:'click me'}).toggle();
}

3. a third option to make it friendlier to close the calendar would be
to use a dialog.

4. beyond that you could extend the datepicker class so that is doesnt
rely on a field, but that is beyond my knowledge.

On Sep 14, 7:56 pm, Chris Kilmer <[email protected]> wrote:
> I've been able to get the datepicker working when:
>
> 1. It's attached to an input element (datapicker pops up when input
> gets focus)
> 2. Datepicker is attached to a span (datepicker is always visibile)
>
> I'm wondering if there is a way to associate a datepicker with a span
> or link element and only have the datepicker show when the element is
> clicked, i.e.
>
> <p>Avg clicks since <span>June 14, 2009</span></p>
>
> So, in this example, the calendar would be hidden until the span
> element is clicked.  When the span is clicked, the calendar displays.
>
> Any advice would be welcome.  Thx.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to