Selecting month in datepicker inside bootstrap-modal will not work in Firefox

The month selected in datepicker does not work in FireFox if it is in a bootable modal format.

<button class="btn" id="btn">Click Me</button>

<div class="modal hide" id="modal" tabindex="-1">
    <div class="modal-body">
        <input type="text" id="datepicker" />        
    </div>
</div>

JavaScript:

$("#datepicker").datepicker({"changeMonth": true});

$('#btn').click(function() {
    $("#modal").modal('show');
});

Below is an example: http://jsfiddle.net/nKXF2/

I found a problem with simitilar twitter-bootstrap github: https://github.com/twbs/bootstrap/issues/5979

+3
source share
3 answers

I found two fixes for this error:

1: tabindex attr div.modal, . , , - , IE ( ) , .

Fix2: : http://jsfiddle.net/nKXF2/1/. , , , .

$('#modal').on('show'function ({
    $.fn.modal.Constructor.prototype.enforceFocus = function ({ };
});

, .

+17

, , . . , Firefox, .: P

0

First, try to detect only the Firefox browser.

	if (navigator.userAgent.toLowerCase().indexOf('firefox') !== -1) {
		$.fn.modal.Constructor.prototype.enforceFocus = function (){};
	}
Run codeHide result
0
source

All Articles