2

ボタンから次を呼び出しています。

var d = $dialog.dialog({dialogFade: 偽、モーダル: 真、backdropClick: 偽}); d.open('html/xyz.html', 'xyzController');

ダイアログにフォーカスがないことを除いて、すべて正常に動作します。TABすると、ページの最後の要素として扱われます。ダイアログにフォーカスを与える方法はありますか??? 私が見つけることができるすべての解決策を試しましたが、成功しませんでした。

ありがとう

4

1 に答える 1

0

ディレクティブを使用して、任意の要素に setFocus を設定できます。

MyApp.directive('CustomSetFocus', [function () {
    return {
        restrict: 'A',
        link: function (scope, element, attrs, controller) {
            scope.$watch(attrs.customSetFocus, function (newValue, oldValue) {
                if (newValue === true) {                        
                        element[0].focus();                        
                }
            });
        }
    };
}]);

次に、次のようにトリガーできます。

<input type="text" id="whatever" custom-set-focus="true"/>

または、おそらく initialize() 関数などで、フォーカスをトリガーするスコープ変数をコントローラーに設定できます。

<input type="text" id="whatever" custom-set-focus="someScopeVariable"/>
于 2013-10-03T17:11:03.323 に答える