jQuery ui datepicker conflict with bootstrap datepicker

前端 未结 8 2216
梦如初夏
梦如初夏 2020-12-01 18:26

I want to show two months using bootstrap datepicker. After search on google I am not able to find how to show multiple months using bootstrap datepicker. I found that I can

相关标签:
8条回答
  • 2020-12-01 19:11

    Bootstrap Datepicker conflict with jquery UI datepicker. f you want to use Bootstrap datepicker then try this

    var datepicker = $.fn.datepicker.noConflict(); // return $.fn.datepicker to previously assigned value
    $.fn.bootstrapDP = datepicker;                 // give $().bootstrapDP the bootstrap-datepicker functionality
    
    // Call bootstrap datepicker function
    $('#datepickermodel').bootstrapDP({
          format: 'dd/mm/yyyy',
          todayHighlight: true
    });
    

    This works for me. I hope this will work for you as well :)

    For more details: https://bootstrap-datepicker.readthedocs.io/en/master/#no-conflict-mode

    0 讨论(0)
  • 2020-12-01 19:11

    Just put this line after calling Bootstrap datepicker

    var _datepicker = jQuery.fn.datepicker;
    

    And after calling jQuery-ui JS

    jQuery.fn.datepicker = _datepicker;
    

    So, your call will looks like

    <script src="/bootstrap-datepicker.js" type="text/javascript"></script>
    var _datepicker = jQuery.fn.datepicker;
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    jQuery.fn.datepicker = _datepicker;
    
    0 讨论(0)
提交回复
热议问题