Skip to content

Commit a27a361

Browse files
committed
wait until page has loaded to set bootstrapKeydown function (#2439)
1 parent 7f57268 commit a27a361

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

js/bootstrap-select.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -3129,8 +3129,8 @@
31293129
return this;
31303130
};
31313131

3132-
// get Bootstrap's keydown event handler for either Bootstrap 4 or Bootstrap 3
3133-
var bootstrapKeydown = $.fn.dropdown.Constructor._dataApiKeydownHandler || $.fn.dropdown.Constructor.prototype.keydown;
3132+
// wait until whole page has loaded to set function in case Bootstrap isn't available yet
3133+
var bootstrapKeydown = function () {};
31343134

31353135
$(document)
31363136
.off('keydown.bs.dropdown.data-api')
@@ -3144,6 +3144,9 @@
31443144
// SELECTPICKER DATA-API
31453145
// =====================
31463146
$(window).on('load' + EVENT_KEY + '.data-api', function () {
3147+
// get Bootstrap's keydown event handler for either Bootstrap 4 or Bootstrap 3
3148+
bootstrapKeydown = $.fn.dropdown.Constructor._dataApiKeydownHandler || $.fn.dropdown.Constructor.prototype.keydown;
3149+
31473150
$('.selectpicker').each(function () {
31483151
var $selectpicker = $(this);
31493152
Plugin.call($selectpicker, $selectpicker.data());

0 commit comments

Comments
 (0)