Reputation: 335
I use require.js. jquery.focus() works on normal html site but doesn't work on bootstrap popup modal. I make a search form which contains this textbox.
define(["common"], function(common) {
function init() {
initFocus();
}
function initFocus() {
$("#p001SearchIDTxt").focus();
}
return {
"init": init
}
});
Upvotes: 1
Views: 1675
Reputation: 4097
Due to how HTML5 defines its semantics, the autofocus HTML attribute has no effect in Bootstrap modals. To achieve the same effect, use some custom JavaScript:
$('#myModal').on('shown.bs.modal', function () {
$("#p001SearchIDTxt").focus();
})
Source: http://v4-alpha.getbootstrap.com/components/modal/
Upvotes: 4