简体   繁体   English

Bootstrap内部的Bootstrap datetimepicker不触发

[英]Bootstrap datetimepicker not firing when inside Boostrap Collapse

I am trying to put a bootstrap datetimerpicker inside of a bootstrap collapse, but when I click on the glyphcon, the calander does not dropdown. 我试图将bootstrap datetimerpicker放在bootstrap崩溃内部,但是当我单击字形图标时,calander不会下拉。 I assume that there is some javascript conflict that is preventing the dropdown of the calander where the user can pick a date. 我假设存在一些JavaScript冲突,阻止了用户可以选择日期的calander下拉菜单。

Here is the code: 这是代码:

        <div class="col-sm-3 sidebar">
        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
          <div class="panel panel-default">
            <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">Request Pickup</h4>
                </div>
              </a>
            <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
              <div class="panel-body">
                <h4>Selected A Date</h4>
                    <div class="row">
                        <div class='col-sm-6'>
                            <div class="form-group">
                                <div class='input-group date' id='datetimepicker1'>
                                    <input type='text' class="form-control" id="delivery_time" />
                                    <span class="input-group-addon">
                                        <span class="glyphicon glyphicon-calendar"></span>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <script type="text/javascript">
                            $(function () {
                                $('#datetimepicker1').datetimepicker({
                                  format: "dd MM yyyy - HH:ii P",
                                  showMeridian: true,
                                  autoclose: true,
                                  todayBtn: false
                                });
                            });
                        </script>
                    </div>
              </div>
            </div>
          </div>
        </div>
    </div>

I am using rails with this gem which works perfectly when not in a collapse. 我正在使用带有此宝石的滑轨,该滑轨在不倒塌时也能正常工作。 Any help or critiques are greatly appreciated. 任何帮助或批评都将不胜感激。 Thanks 谢谢

Looks like you either provided an incorrect link, or may be referring to the incorrect documentation; 看起来您提供的链接不正确,或者所引用的文档不正确; as most options you are using are not part of the datetimepicker in question http://eonasdan.github.io/bootstrap-datetimepicker/Options/ 由于您使用的大多数选项都不是有问题的datetimepicker的一部分,因此http://eonasdan.github.io/bootstrap-datetimepicker/Options/

It's hard to tell what format you are trying to use for your date, as you are not using valid moment format(s) http://momentjs.com/docs/#/displaying/format/ 由于您未使用有效的时间格式,因此很难说出您要为日期使用哪种格式http://momentjs.com/docs/#/displaying/format/

You will also likely need to add some custom CSS to allow for overflow: visible; 您可能还需要添加一些自定义CSS来允许overflow: visible; on Bootstrap panels. 在Bootstrap面板上。

Provided we are talking about the right datetimepicker, something like this should get you going. 如果我们正在谈论正确的日期时间选择器,则类似的内容应该可以帮助您前进。 You will have to play with the moment formats to suit your needs. 您将必须使用适合您需要的时刻格式。

See Fiddle : http://jsfiddle.net/spasticdonkey/6g7j55f2/3/ 参见小提琴http : //jsfiddle.net/spasticdonkey/6g7j55f2/3/

$(function () {
    $("#datetimepicker1").datetimepicker({
        format: "DD MM YYYY - HH:mm Z",
        useCurrent: false
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM