Set focus on group field after adding

This commit is contained in:
Thomas Müller 2016-03-07 22:50:03 +01:00 committed by Jan-Christoph Borchardt
parent d9bdc42176
commit 62cc23d37d
3 changed files with 11 additions and 3 deletions

View File

@ -8,7 +8,11 @@ app.directive('focusExpression', function ($timeout) {
if (attrs.focusExpression) {
if (scope.$eval(attrs.focusExpression)) {
$timeout(function () {
element[0].focus();
if (element.is('input')) {
element.focus();
} else {
element.find('input').focus();
}
}, 100); //need some delay to work with ng-disabled
}
}

View File

@ -56,7 +56,11 @@ app.directive('focusExpression', function ($timeout) {
if (attrs.focusExpression) {
if (scope.$eval(attrs.focusExpression)) {
$timeout(function () {
element[0].focus();
if (element.is('input')) {
element.focus();
} else {
element.find('input').focus();
}
}, 100); //need some delay to work with ng-disabled
}
}

View File

@ -1,7 +1,7 @@
<label ng-if="ctrl.availableOptions.length === 0" for="details-{{ctrl.name}}">{{ctrl.meta.readableName}}</label>
<ui-select id="details-{{ctrl.name}}" multiple tagging tagging-label="{{ctrl.t.newGroup}}" ng-model="ctrl.data.value" group-model
on-remove="ctrl.model.updateContact()" on-select="ctrl.model.updateContact()"
theme="select2">
theme="select2" focus-expression="$parent.$parent.ctrl.focus === ctrl.name">
<ui-select-match placeholder="{{ctrl.meta.readableName}}">{{$item}}</ui-select-match>
<ui-select-choices repeat="group in ctrl.availableGroups | filter:$select.search">
{{group}}