JQuery UI Datepicker: Making a link trigger datepicker


JQuery UI Datepicker: Making a link trigger datepicker



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

implemented here:

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

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?




Richfaced rendering takes longer time

1:



Maintaining RichFaces panelMenu state between requests
You could do something like I did in this fiddle.
Replacing JavaServer Faces Error Pages
HTML:.
File upload using RichFaces
<a href="#" id="toggleDP">Toggle</a> 
JS:.
How to generate facelets documentation?
var $dp = $("<input type='text' />").hide().datepicker({     onSelect: function(dateText, inst) {        $("body").append("<div>Selected "+dateText+"</div>");     } }).appendTo('body');  $("#toggleDP").button().click(function(e) {     if ($dp.datepicker('widget').is(':hidden')) {         $dp.show().datepicker('show').hide();         $dp.datepicker("widget").position({             my: "left top",             at: "right top",             of: this         });     } else {         $dp.hide();     }      //e.preventDefault(); }); 


JSF Nested EXpression language


Jsf control that format text with html tags [duplicate]

2:



JSF boolean output
I just solved this very easily in my app -- if you have your datepicker open with a text field, you can use this solution too.

I added a $('#date_field').focus() link to the icon.

Click the icon, the text field gets focus and that triggers the datepicker to open.

Voila..


3:


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. .


4:


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>


5:


Based on @camilokawerin answer, I did this and I find it the easieast and cleanest solution:. HTML:.
<a href="#" id="selec">Click</a> <div id="datepicker" style="display:none"></div> 
JS:.
$("#datepicker").datepicker(); $('#selec').click(function(){     $('#datepicker').toggle(); }); 


6:


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 }); 


7:


With inline datepicker is pretty easier to do this.

Check my JSFiddle.. HTML.
<a href="#" class="datepicker">Pick a date</a> 
JS.
var dpToggler = $('a.datepicker').button(),     dp = $("<div />").css('position', 'absolute').hide().datepicker().appendTo(dpToggler);  dpToggler.on('click', function(e) {   e.preventDefault();   if (dp.is(':hidden')) {     dp.show().position({       my: 'left top',       at: 'right top',       of: this     });   } else {     dp.hide();   } }); 



87 out of 100 based on 57 user ratings 807 reviews