Created
January 4, 2012 19:10
-
-
Save happyboredom/1561512 to your computer and use it in GitHub Desktop.
Prevent jQueryUI dialog from setting focus on links or form fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(selector).dialog({ | |
open: function (evt, ui) { | |
$(':focus', this).blur(); | |
}, | |
width:400, | |
height:250, | |
modal:true, | |
title:'Help' | |
}); |
UI Dialog checks for focus when the [Esc] key is pressed and will only close the dialog at that time if it has focus. You're better off retaining dialog focus, but removing focus styles (outline, etc) in your CSS.
Just ran into the case and landed at the link. Added the follows to fix.
.ui-dialog :focus {
outline: -webkit-focus-ring-color auto 0px !important;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I started with
:tabbable
selector but I think that it is only available in jqueryUI. The:focus
selector is part of regulary jQuery and works just as well.