javascript - issue in rendering jquery datetimepicker into a modal -
i trying show jquery datetimepicker bootstrap modal..
html:
<div class="modal fade" id="availability_modal" role="dialog"> <div class="modal-dialog"> <!-- modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> × </button> <h4 class="modal-title">view availability of %supp_name%</h4> </div> <div class="modal-body"> <div id="availability_calender"></div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal"> close </button> </div> </div> </div>
and jquery used is...
$(document).on("click","#open_availability",function(e){ settimeout(function(){ jquery('#availability_calender').datetimepicker({ formatdate: "d.m.y", inline:true, timepicker:false, highlighteddates: [ "29.02.2016,meeting pete", "24.02.2016,christmas eve,xdsoft_highlighted_mint", "25.02.2016,christmas day,xdsoft_highlighted_mint", "26.02.2016,thanksgiving" ], highlightedperiods: [ "27.04.2015,08.05.2015,business trip", "11.07.2015,31.08.2015,summer holiday 2015,xdsoft_highlighted_mint", "21.12.2015,01.01.2016,christmas holiday 2015" ] }); },1000); });
it works fine when not rendering modal... appreciated
i not sure why want div
element initialize datetimepicker
, suggest change element form input
same id.
there callback, when modal shows in browser shown.bs.modal
, can initialize datetimepicker
in it:
jquery('#availability_modal').on('shown.bs.modal', function() { jquery('#availability_calender').datetimepicker({ formatdate: "d.m.y", inline: true, timepicker: false, highlighteddates: [ "29.02.2016,meeting pete", "24.02.2016,christmas eve,xdsoft_highlighted_mint", "25.02.2016,christmas day,xdsoft_highlighted_mint", "26.02.2016,thanksgiving" ], highlightedperiods: [ "27.04.2015,08.05.2015,business trip", "11.07.2015,31.08.2015,summer holiday 2015,xdsoft_highlighted_mint", "21.12.2015,01.01.2016,christmas holiday 2015" ] }); })
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.1/jquery.datetimepicker.css"> <link rel="stylesheet" type="text/css" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.min.js"></script> <script type="text/javascript" src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script> <script> date.parsedate = function(input, format) { return moment(input, format).todate(); }; date.prototype.dateformat = function(format) { return moment(this).format(format); }; </script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.1/jquery.datetimepicker.min.js"></script> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#availability_modal"> launch demo modal </button> <div class="modal fade" id="availability_modal" role="dialog"> <div class="modal-dialog"> <!-- modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> × </button> <h4 class="modal-title">view availability of %supp_name%</h4> </div> <div class="modal-body"> <div id="availability_calender"></div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal"> close </button> </div> </div> </div>
Comments
Post a Comment