Bootstrap datetime picker in Modal mode not appearing

levi palmer

I am trying to implement a datetime picker of bootstrap in modal view such as this screenshot below:

enter image description here

My code is as follows:

HTML:

<div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="H3">Add New Overtime</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <div class='input-group date' id='ot_date'>
                                    <input type='text' class="form-control datepicker" placeholder="Enter OT Date" />
                                    <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class='input-group date' id='ot_timein'>
                                    <input type='text' class="form-control" placeholder="Enter OT Time-in"/>
                                    <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class='input-group date' id='ot_timeout'>
                                    <input type='text' class="form-control" placeholder="Enter OT Time-out" />
                                    <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span>
                                </div>
                            </div>

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                Close
                            </button>
                            <button type="submit" class="btn btn-primary">
                                Save
                            </button>
                        </div>

                    </div>

JS:

<script type="text/javascript">
$(document).ready(function() {
    $('#ot_date').datetimepicker();

    $('#ot_timein').datetimepicker({
        language: 'en',
        pick12HourFormat: true
    });

    $('#ot_timeout').datetimepicker({
        language: 'en',
        pick12HourFormat: true
    });
});

I have checked the following links but still no definite answer.

Query1 - DateTime picker in bootstrap is not working

Query 2 - Twitter bootstrap datetime-picker not showing properly in modal

Query 3 - Bootstrap datetime-picker showing in modal as partial

levi palmer

First of all, thanks a lot to @Guruprasad Rao for giving me an idea whats missing in my code. There I found in the console that Moment.js is needed first before calling the bootstrap-datetimepicker.js. So you can download the Moment.js from here.

In my code, I implemented, as follows:

<script src="<?php echo base_url(); ?>assets/bootstrap/plugins/datetimepicker/js/moment.js"></script>
<script src="<?php echo base_url(); ?>assets/bootstrap/plugins/datetimepicker/js/bootstrap-datetimepicker.js"></script>

REMINDER: Moment.js MUST be called first before datetimepicker.js

Secondly, thanks a lot to @Melvas. I salute you men. Thanks for correcting my code. As you said, the ID="ot_date" is added in the input element NOT in the DIV. Great mind...

So implementing the two changes I mentioned above, I got this screenshot below. The calendar now works as expected. enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rails Bootstrap Modal not appearing

From Dev

Twitter Bootstrap Modal - not appearing

From Dev

Rails Bootstrap Modal not appearing

From Dev

Bootstrap 3 modal form not appearing

From Java

Bootstrap modal appearing under background

From Dev

Bootstrap 3 modal form not appearing

From Dev

Bootstrap Datetime picker?

From Dev

Bootstrap datetime picker plugin is not working?

From Dev

Bootstrap datetime picker disable hours

From Dev

Small fonts on Bootstrap DateTime picker

From Dev

Bootstrap Datepicker appearing at incorrect location in a modal

From Dev

jQuery datapicker appearing behind twitter bootstrap modal

From Dev

Bootstrap modal with opacity appearing behind the background

From Dev

time-picker in bootstrap modal dialog

From Dev

bootstrap modal box open jquery location picker

From Dev

time-picker in bootstrap modal dialog

From Dev

Require Bootstrap date picker always in open mode

From Dev

Can not get bootstrap datetime picker to display properly

From Dev

Bootstrap datetime picker picking day before selected

From Dev

Bootstrap datetime picker disable past time

From Dev

Bootstrap DateTime Picker set default date to yesterday

From Dev

Bootstrap Datetime picker z-index

From Dev

Can not get bootstrap datetime picker to display properly

From Dev

Bootstrap Datetime picker z-index

From Dev

Edit background in inactive days in DateTime Picker Bootstrap

From Dev

bootstrap date and time picker not working on bootstrap-modal?

From Dev

Twitter bootstrap modal appearing in wrong location, not centered and the buttons are not clickable

From Dev

Why does this jQuery color picker fail within a Bootstrap modal?

From Dev

Why does this jQuery color picker fail within a Bootstrap modal?

Related Related

  1. 1

    Rails Bootstrap Modal not appearing

  2. 2

    Twitter Bootstrap Modal - not appearing

  3. 3

    Rails Bootstrap Modal not appearing

  4. 4

    Bootstrap 3 modal form not appearing

  5. 5

    Bootstrap modal appearing under background

  6. 6

    Bootstrap 3 modal form not appearing

  7. 7

    Bootstrap Datetime picker?

  8. 8

    Bootstrap datetime picker plugin is not working?

  9. 9

    Bootstrap datetime picker disable hours

  10. 10

    Small fonts on Bootstrap DateTime picker

  11. 11

    Bootstrap Datepicker appearing at incorrect location in a modal

  12. 12

    jQuery datapicker appearing behind twitter bootstrap modal

  13. 13

    Bootstrap modal with opacity appearing behind the background

  14. 14

    time-picker in bootstrap modal dialog

  15. 15

    bootstrap modal box open jquery location picker

  16. 16

    time-picker in bootstrap modal dialog

  17. 17

    Require Bootstrap date picker always in open mode

  18. 18

    Can not get bootstrap datetime picker to display properly

  19. 19

    Bootstrap datetime picker picking day before selected

  20. 20

    Bootstrap datetime picker disable past time

  21. 21

    Bootstrap DateTime Picker set default date to yesterday

  22. 22

    Bootstrap Datetime picker z-index

  23. 23

    Can not get bootstrap datetime picker to display properly

  24. 24

    Bootstrap Datetime picker z-index

  25. 25

    Edit background in inactive days in DateTime Picker Bootstrap

  26. 26

    bootstrap date and time picker not working on bootstrap-modal?

  27. 27

    Twitter bootstrap modal appearing in wrong location, not centered and the buttons are not clickable

  28. 28

    Why does this jQuery color picker fail within a Bootstrap modal?

  29. 29

    Why does this jQuery color picker fail within a Bootstrap modal?

HotTag

Archive