diff --git a/README.md b/README.md
index f56b69f..6d7fb87 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ A list of search keywords/phrases to be associated with the contentObject/articl
No known limitations.
----------------------------
-**Version number:** 4.0.0
+**Version number:** 4.0.1
**Framework versions:** 5.8+
**Author / maintainer:** Kineo and community with [contributors](https://github.com/cgkineo/adapt-search/graphs/contributors)
**Accessibility support:** WAI AA
diff --git a/bower.json b/bower.json
index 49fb2e9..245cad4 100644
--- a/bower.json
+++ b/bower.json
@@ -4,7 +4,7 @@
"type": "git",
"url": "git://github.com/cgkineo/adapt-search"
},
- "version": "4.0.0",
+ "version": "4.0.1",
"framework": ">=5.8",
"homepage": "https://github.com/cgkineo/adapt-search",
"issues": "https://github.com/cgkineo/adapt-search/issues/",
diff --git a/js/adapt-search.js b/js/adapt-search.js
index f4f1524..fcb62c9 100644
--- a/js/adapt-search.js
+++ b/js/adapt-search.js
@@ -1,4 +1,5 @@
import Adapt from 'core/js/adapt';
+import data from 'core/js/data';
import SearchDrawerItemView from './searchDrawerItemView';
import SearchResultsView from './searchResultsView';
import SEARCH_DEFAULTS from './SEARCH_DEFAULTS';
@@ -19,6 +20,9 @@ class Search extends Backbone.Controller {
'drawer:closed': this.onDrawerClosed,
'drawer:noItems': this.onNoItems
});
+ this.listenTo(data, {
+ 'add remove change:_isAvailable change:_isLocked': this.reIndex
+ });
}
onDataReady() {
@@ -32,12 +36,16 @@ class Search extends Backbone.Controller {
const modelWithDefaults = $.extend(true, {}, SEARCH_DEFAULTS, model);
Adapt.course.set('_search', modelWithDefaults);
this.isSetup = true;
- window.search = this.searcher = new Searcher();
+ this.reIndex();
}
clearSearchResults() {
this.query('');
this.addDrawerItem();
+ this.reIndex();
+ }
+
+ reIndex() {
if (!this.isSetup) return;
window.search = this.searcher = new Searcher();
}