From 9c702862586a841507140e9404ac27d2fdad9fec Mon Sep 17 00:00:00 2001 From: tanshu Date: Sun, 11 Jan 2015 12:28:27 +0530 Subject: [PATCH] Fix: The new focusing directive wanted exclusive scope and it conflicted at times. Fixed. --- brewman/static/partial/journal.html | 4 ++-- brewman/static/scripts/angular_directive.js | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/brewman/static/partial/journal.html b/brewman/static/partial/journal.html index 0d8ce0f4..d6a488a5 100644 --- a/brewman/static/partial/journal.html +++ b/brewman/static/partial/journal.html @@ -7,7 +7,7 @@
+ is-open="dOpen" ng-focus="dOpen = true" ng-model="voucher.Date"/> @@ -26,7 +26,7 @@
+ typeahead-editable="false" on-return="add()" focus-on="foAccount"/>
diff --git a/brewman/static/scripts/angular_directive.js b/brewman/static/scripts/angular_directive.js index 5a809e27..57baec30 100644 --- a/brewman/static/scripts/angular_directive.js +++ b/brewman/static/scripts/angular_directive.js @@ -378,19 +378,18 @@ overlordDirective.directive('fileUpload', function () { }; }); -overlordDirective.directive('focusOn', ['$timeout', function ($timeout) { +overlordDirective.directive('focusOn', ['$timeout', '$parse', function ($timeout, $parse) { return { restrict: 'A', - scope: { - focusOn: '=' - }, link: function (scope, element, attrs) { - scope.$watch('focusOn', function (value) { + scope.$watch(attrs.focusOn, function (value) { if (value === true) { - //$timeout(function () { - element[0].focus(); - scope.focusOn = false; - //}); + var getter = $parse(attrs.focusOn); + var setter = getter.assign; + setter(scope, false); + $timeout(function () { + element[0].focus(); + }); } }); }