views:

838

answers:

3

Hi Guys,

I am using JQuery's UI datepicker: http://jqueryui.com/demos/datepicker/

implemented here:

http://www.clients.eirestudio.net/dermot/

I want to use a link as the trigger but I can't get it to work.

Here is my code:

// JQuery UI
$("#datepicker").datepicker({
      changeMonth: true,
      changeYear: true,
      maxDate: '0m 0d',
      minDate: new Date(2000, 1 - 1, 1),
      dateFormat: 'dd-mm-yy'
});

<p class="clearfix hidden">
    <input id="" class="input float datepicker" type="input" name="" value="" />
    <a class="calendar ui-icon ui-icon-calendar">Date</a>

    <span class="mid-info">To</span>
    <input id="" class="input datepicker" type="input" name="" value="" />
    <a class="calendar" href="#">Date</a>
</p>

Any ideas?

A: 

From jqueryui, it seems like you should add showOn and maybe (don't know if it's required) buttonImage:

$("#datepicker").datepicker({
    changeMonth: true,
    changeYear: true,
    maxDate: '0m 0d',
    minDate: new Date(2000, 1 - 1, 1),
    dateFormat: 'dd-mm-yy',
    showOn: 'button', 
    buttonImage: 'images/calendar.gif', // adapt this to your image
    buttonImageOnly: true
});
Tom Bartel
Thanks for the reply. Unfortunately I tried that and it doesn't seem to work also.
Keith Donegan
I somehow forgot the `datepicker()` function before, and the `buttonImage` property must probably be adapted, as your own answer suggests. Sorry about the inaccuracy.
Tom Bartel
+2  A: 

This might help somebody else.

I ended up getting it to work with JQuery UI.

Code below:

$(".date-pick").datepicker({
      changeMonth: true,
      changeYear: true,
      maxDate: '0m 0d',
      minDate: new Date(2000, 1 - 1, 1),
      dateFormat: 'dd-mm-yy',
      showOn: 'button', 
      buttonImage: 'http://www.example.com/elements/images/calendar.png', 
      buttonImageOnly: true
      });

and I changed the datepicker id to date-pick class

Keith Donegan
A: 

Try using:

    <a href="javascript:void(0);" onclick="$.datepicker._showDatepicker($('#inputID')[0]);">Text here</a>
    <input type="hidden" id="inputID"/>
    ...
    <script type="text/javascript">
      $(document).ready(
         function()
         {
             $('#inputID').datepicker();
         }
      );
    </script>
Zsolti