I have a text box inside angular ui modal, and you need to set focus on it when the modal image becomes visible, it cannot be in the document loading, because it only works for the first time, opening the modal.
Modals have animation to open, I need to set focus after the animation is complete.
Based on the other issues studied here, I created the following directive:
.directive('focusMe', ['$timeout', focusMe]); function focusMe($timeout) { return function (scope, element) { scope.$watch(function () { $timeout(function () { element[0].focus(); }); }); }; };
But this directive always checks the focus of the text area. Since my modal has a different input field, when I click on it, the focus again changes to a text field that uses the directive. How to set focus only for the first time so that the modality becomes visible?
UPDATE
Additional Information: The problem of always keeping the focus on textarea has been resolved, in some way.
But since my modal has fading in the animation, in IE, the focus is displayed above the text box, on the outside, I need to use a timeout for IE to properly set the focus. This is not very nice. Any better way?
source share