You are right, I've shown demos on how you can call jQuery's native jQuery.fn.focus()
method on a DOM element, as that's all ui-jq
really does. The trick is getting it to fire multiple times, and at the right time.
ui-jq
already executes the method for you inside a $timeout
, however by default it only fires once, when the DOM element is created. In order to make ui-jq
fire multiple times, simply add ui-refresh="someExpression"
and use an expression that you know will change every single time the modal opens. It's alright if it refires when the modal is closed too, .focus()
will do nothing if the DOM element is not visible.
So, for the ui-bootstrap modal, simply put the same expression you're using inside the modal="someExpression"
and you should be set.