Fix: The new focusing directive wanted exclusive scope and it conflicted at times. Fixed.

This commit is contained in:
tanshu 2015-01-11 12:28:27 +05:30
parent 948b45b2ce
commit 9c70286258
2 changed files with 10 additions and 11 deletions

View File

@ -7,7 +7,7 @@
<div class="col-md-10"> <div class="col-md-10">
<div class="input-group"> <div class="input-group">
<input class="form-control" id="txtDate" type="text" datepicker-popup="dd-MMM-yyyy" <input class="form-control" id="txtDate" type="text" datepicker-popup="dd-MMM-yyyy"
is-open="dOpen" ng-focus="dOpen = true" ng-model="voucher.Date" focus-on="foAccount"/> is-open="dOpen" ng-focus="dOpen = true" ng-model="voucher.Date"/>
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button> <button class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>
</span> </span>
@ -26,7 +26,7 @@
<div class="col-md-4"> <div class="col-md-4">
<input type="text" id="txtAccount" class="form-control" ng-model="account" <input type="text" id="txtAccount" class="form-control" ng-model="account"
typeahead="account as account.Name for account in accounts($viewValue)" typeahead="account as account.Name for account in accounts($viewValue)"
typeahead-editable="false" on-return="add()"/> typeahead-editable="false" on-return="add()" focus-on="foAccount"/>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div class="input-group"> <div class="input-group">

View File

@ -378,19 +378,18 @@ overlordDirective.directive('fileUpload', function () {
}; };
}); });
overlordDirective.directive('focusOn', ['$timeout', function ($timeout) { overlordDirective.directive('focusOn', ['$timeout', '$parse', function ($timeout, $parse) {
return { return {
restrict: 'A', restrict: 'A',
scope: {
focusOn: '='
},
link: function (scope, element, attrs) { link: function (scope, element, attrs) {
scope.$watch('focusOn', function (value) { scope.$watch(attrs.focusOn, function (value) {
if (value === true) { if (value === true) {
//$timeout(function () { var getter = $parse(attrs.focusOn);
var setter = getter.assign;
setter(scope, false);
$timeout(function () {
element[0].focus(); element[0].focus();
scope.focusOn = false; });
//});
} }
}); });
} }