Require Bootstrap date picker always in open mode

隐身守侯 提交于 2019-12-07 21:12:35

问题


How can i get Require Bootstrap date picker always in open mode?

I am using bootstrap date picker in one of my application.

Requirement is like date picker should be open when page load and it should be always in open mode after selection as well.

I found that it can manageable through autoclose: false property but, if i click out side of date picker it's getting close.

It should be there always in open mode.

I hope there is any property which can make it possible, Please find following function which i am using.

HTML

 <input type="text" id="select_date" class="selecteShipDate" />

Script

<script src="assets/js/bootstrap-datepicker.js"></script>                                                                                       
<script type="text/javascript">
    $(function () {
        $('#select_date').datepicker({
            format: 'dd MM yyyy',
            autoclose: false
        })
    });
</script>

回答1:


Have a look at Mark Amery's answer. This should work for you too.

$(document).ready(function () {
    $input = $("#select_date");
    $input.datepicker({
        format: 'dd MM yyyy'
    });
    $input.data('datepicker').hide = function () {};
    $input.datepicker('show');
});

I here is a working demo




回答2:


    $('#datepicker').datepicker();
    $('#datepicker').on('changeDate', function() {
        $('#my_hidden_input').val(
            $('#datepicker').datepicker('getFormattedDate')
        );
    });

    <div id="datepicker" data-date="12/03/2012"></div>
    <input type="hidden" id="my_hidden_input">


来源:https://stackoverflow.com/questions/28622555/require-bootstrap-date-picker-always-in-open-mode

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