Merge pull request #1875 from velesin/search_controller_context_binding_fix
Refactors Discourse.SearchController to use var self = this; convention
This commit is contained in:
commit
0420df14f3
|
@ -23,18 +23,18 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, {
|
||||||
}.observes('term', 'typeFilter'),
|
}.observes('term', 'typeFilter'),
|
||||||
|
|
||||||
searchTerm: Discourse.debouncePromise(function(term, typeFilter) {
|
searchTerm: Discourse.debouncePromise(function(term, typeFilter) {
|
||||||
var searchController = this;
|
var self = this;
|
||||||
this.set('resultCount', 0);
|
self.set('resultCount', 0);
|
||||||
|
|
||||||
var searcher = Discourse.Search.forTerm(term, {
|
var searcher = Discourse.Search.forTerm(term, {
|
||||||
typeFilter: typeFilter,
|
typeFilter: typeFilter,
|
||||||
searchContext: searchController.get('searchContext')
|
searchContext: self.get('searchContext')
|
||||||
});
|
});
|
||||||
|
|
||||||
return searcher.then(function(results) {
|
return searcher.then(function(results) {
|
||||||
searchController.set('results', results);
|
self.set('results', results);
|
||||||
if (results) {
|
if (results) {
|
||||||
searchController.set('noResults', results.length === 0);
|
self.set('noResults', results.length === 0);
|
||||||
|
|
||||||
var index = 0;
|
var index = 0;
|
||||||
results = _(['topic', 'category', 'user'])
|
results = _(['topic', 'category', 'user'])
|
||||||
|
@ -49,11 +49,11 @@ Discourse.SearchController = Em.ArrayController.extend(Discourse.Presence, {
|
||||||
})
|
})
|
||||||
.value();
|
.value();
|
||||||
|
|
||||||
searchController.set('resultCount', index);
|
self.set('resultCount', index);
|
||||||
searchController.set('content', results);
|
self.set('content', results);
|
||||||
}
|
}
|
||||||
|
|
||||||
searchController.set('loading', false);
|
self.set('loading', false);
|
||||||
});
|
});
|
||||||
}, 300),
|
}, 300),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue