Skip to content

Commit

Permalink
Improved initialization and closing with remote fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
indrimuska committed Jun 18, 2016
1 parent 27a464c commit ab315ba
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-selector",
"version": "1.3.14",
"version": "1.3.15",
"authors": [
"Indri Muska <indrimuska@gmail.com>"
],
Expand Down
17 changes: 10 additions & 7 deletions dist/angular-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,14 @@
if (!angular.isDefined(scope.remoteValidation))
scope.remoteValidation = false;
if (scope.remote)
$q.when(!scope.hasValue() || !scope.remoteValidation
? angular.noop
: scope.fetchValidation(scope.value)
).then(function () {
scope.$watch('search', function () {
$timeout(scope.fetch);
$timeout(function () {
$q.when(!scope.hasValue() || !scope.remoteValidation
? angular.noop
: scope.fetchValidation(scope.value)
).then(function () {
scope.$watch('search', function () {
$timeout(scope.fetch);
});
});
});

Expand Down Expand Up @@ -273,6 +275,7 @@
scope.close = function () {
scope.isOpen = false;
scope.resetInput();
if (scope.remote) $timeout(scope.fetch);
};
scope.decrementHighlighted = function () {
scope.highlight(scope.highlighted - 1);
Expand Down Expand Up @@ -600,4 +603,4 @@
return new Selector($filter, $timeout, $window, $http, $q);
}]);

})(window.angular);
})(window.angular);
4 changes: 2 additions & 2 deletions dist/angular-selector.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-selector",
"version": "1.3.14",
"version": "1.3.15",
"description": "A native AngularJS directive that transform a simple `<select>` box into a full html select with typeahead.",
"main": "src/angular-selector.js",
"repository": {
Expand Down
17 changes: 10 additions & 7 deletions src/angular-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,14 @@
if (!angular.isDefined(scope.remoteValidation))
scope.remoteValidation = false;
if (scope.remote)
$q.when(!scope.hasValue() || !scope.remoteValidation
? angular.noop
: scope.fetchValidation(scope.value)
).then(function () {
scope.$watch('search', function () {
$timeout(scope.fetch);
$timeout(function () {
$q.when(!scope.hasValue() || !scope.remoteValidation
? angular.noop
: scope.fetchValidation(scope.value)
).then(function () {
scope.$watch('search', function () {
$timeout(scope.fetch);
});
});
});

Expand Down Expand Up @@ -273,6 +275,7 @@
scope.close = function () {
scope.isOpen = false;
scope.resetInput();
if (scope.remote) $timeout(scope.fetch);
};
scope.decrementHighlighted = function () {
scope.highlight(scope.highlighted - 1);
Expand Down Expand Up @@ -600,4 +603,4 @@
return new Selector($filter, $timeout, $window, $http, $q);
}]);

})(window.angular);
})(window.angular);

0 comments on commit ab315ba

Please sign in to comment.