Skip to content

Commit

Permalink
set up hooks to autocomplete explorer searching. closes #143
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Mason committed May 12, 2016
1 parent a8227b5 commit 1e55c0a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/assets/javascripts/search.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
$(document).ready(function() {
autocompleteCourseSearch();
autocompleteWishlist();
autocompleteCourseExplorer();
});

$(document).on('page:load', function() {
autocompleteCourseSearch();
autocompleteWishlist();
autocompleteCourseExplorer();
});

function autocompleteCourseSearch() {
Expand All @@ -27,3 +29,19 @@ function autocompleteWishlist() {
});
}

function autocompleteCourseExplorer() {
var explorerForm = '#explorer_main form ';
$(explorerForm + '#search').autocomplete({
source: '/courses/autocomplete.json',
select: function(event, ui) {
$(explorerForm + '#search').val(ui.item.val);
}
});

$(explorerForm + '#professor').autocomplete({
source: '/professors/autocomplete.json',
select: function(event, ui) {
$(explorerForm + '#professor').val(ui.item.label);
}
});
}

0 comments on commit 1e55c0a

Please sign in to comment.