jquery keeping date picker open all the time

耗尽温柔 提交于 2019-12-17 20:49:12

问题


Normal behavior of datepicker is to open when a texbox is clicked and close when a date is selected(clicked). What I need to do is Keep it open from form load and allow user to click repeatedly.I am handling the click event

thanks


回答1:


According to the documentation, you can call it on a div instead of an input and it will stay open and be inline. http://jqueryui.com/demos/datepicker/#inline

You could use it's onSelect event to handle when a date is selected.




回答2:


If you are using the jQuery UI datepicker, use this:

http://jqueryui.com/demos/datepicker/#inline

You can then handle the click event and add the selected date to the text field.




回答3:


I totally agree with @Corbin I would like to provide full example so that help someone in details.

If you want to to have jQueryui calendar default open also capture the click event of calendar follow bellow steps:

HTML Code:

  <div id="myDatePicker" class="DateBox datepicker" style="width:100%;height:200px;"></div>
  <input type="hidden" id="dateHidden" name="dateHidden" />

and your script should look like bellow:

<script>
  $( function() {
    $( ".datepicker" ).datepicker({ 
      altField: "#dateHidden",
      dateFormat: 'yy-mm-dd'})
     .datepicker("setDate", "0");
 } );
</script>

and you can get the selected value of date like bellow code:

<script>

   $("#dateHidden").on('input propertychange paste', function(){

      var Loc = $("#Cafe").val();
      var PDate = $("#dateHidden").val();
      //------Functions you call or actions you perform--------//
      //GetLoc(Loc,PDate);

 });

</script>


来源:https://stackoverflow.com/questions/8531867/jquery-keeping-date-picker-open-all-the-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!