jquery - Autofocus input in twitter bootstrap modal -
hi everyone!
i have such problem - need autofocus element within twitter bootstrap modal (after shows). tricky part here - content of modal loaded using 'data-remote' (jquery.load method) separate html file, so
$(document).on('shown', ".modal", function() { $('[autofocus]', this).focus(); });
works if modal loaded before. question - how create autofocus work @ first time modal loads. in advance!
i'm using bootstrap 3.0 (hopefully, works 3.1 well).
we had utilize tabindex="-1"
because allows esc key close modal.
so able prepare issue using:
// every time modal shown, if has autofocus element, focus on it. $('.modal').on('shown.bs.modal', function() { $(this).find('[autofocus]').focus(); });
jquery twitter-bootstrap modal-dialog
No comments:
Post a Comment