Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change month and year not working in bootstrap modal window

In my project i am using jquery datepicker.It works well in all pages but it's not working in bootstrap modal window.Below is my code for loading datepicker.

  $("#StartDate").datepicker({
                                changeMonth : true,
                                changeYear : true,
                                dateFormat : "yy-mm-dd",
                            });

Now, I cannot able to change month and year from datepicker dropdown. How to fix this issue?Any help will be greatly appreciated!!!

like image 831
Madhesh Avatar asked Apr 02 '15 06:04

Madhesh


2 Answers

While searching more on it, I found it is already answered in another StackOverflow post. Here is some working code, taken from there:

var enforceModalFocusFn = $.fn.modal.Constructor.prototype.enforceFocus;
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
like image 136
Jitender Avatar answered Sep 19 '22 04:09

Jitender


Try this.

Why aren't you using bootstrap datepicker?

<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>
like image 38
Danish Khan Avatar answered Sep 20 '22 04:09

Danish Khan