Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround for initial facets load #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Could use cleaning and refactoring.
- solr-facet-list needs to be declared before solr-search if
preload=true. Otherwise the facets are not registered for initial
display.
- Initial facets registration workaround with hitting "search" button automatically on page load - implemented. http://stackoverflow.com/questions/26494948/automatically-click-button-after-page-load-in-angularjs



Expand Down
18 changes: 17 additions & 1 deletion app/js/solr.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ var solr = angular.module("solr", [])
if (scope.preload){
scope.search(scope.query, scope.rows);
}
scope.autoClicked = function () {
scope.search(scope.query, scope.rows);
}
}

}
Expand Down Expand Up @@ -268,4 +271,17 @@ var solr = angular.module("solr", [])
ctrl.solrUrl = scope.solrUrl;
}
};
});
})

.directive("onLoadClicker", function($timeout) {
return {
restrict: "A",
priority: -1,
link: function(scope, iElm, iAttrs, controller) {
$timeout(function() {
iElm.triggerHandler('click');
}, 0);
}
};
}
);
2 changes: 1 addition & 1 deletion app/view/solr_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
ng-model="rows"
ng-options="r for r in roptions">
</select>
<button type="submit">Search</button>
<button type="submit" ng-click="autoClicked()" on-load-clicker>Search</button>
</form>