Bootstrap datetimepicker installation/configuration

浪子不回头ぞ 提交于 2019-12-11 12:19:28

问题


I'm having some issues with a basic configuration of the eonasdan bootstrap datetimepicker.

I created a fiddle using the code from their basic setup instructions to show my configuration. I see another Stackoverflow question on this topic that has another fiddle with older versions of the same plugins. The two fiddles look similar, but mine doesn't work.

<div class="container">
    <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" />
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            $(function () {
                $('#datetimepicker1').datetimepicker();
            });
        </script>
    </div>
</div>

Why doesn't the datetime picker in my fiddle work?


回答1:


If you run your fiddle while inspecting the console you will see the following error:

uncaught exception: bootstrap-datetimepicker requires Moment.js to be loaded first

So it's simply a matter of the order in which the scripts are loaded. This is exactly the same fiddle, except bootstrap-datetimepicker.min.js is loaded last, and it works.

Just take care of loading the resources in the right order, or use a dependency management tool to sort it out for you.



来源:https://stackoverflow.com/questions/32026039/bootstrap-datetimepicker-installation-configuration

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