Permalink
Browse files

Add 'no results found' to instantsearch as appropriate

Fixes gh-1
  • Loading branch information...
1 parent 1782a5b commit 43ae187893a6bf7326eefd41db287f4c2ffc099a @sean-k sean-k committed Jun 20, 2011
Showing with 10 additions and 1 deletion.
  1. +5 −0 jquery.indextank.ajaxsearch.js
  2. +1 −1 jquery.indextank.instantsearch.js
  3. +4 −0 jquery.indextank.renderer.js
@@ -39,13 +39,18 @@
// make it possible for other to trigger an ajax search
base.$el.bind( "Indextank.AjaxSearch.runQuery", base.runQuery );
+ base.$el.bind( "Indextank.AjaxSearch.displayNoResults", base.displayNoResults );
};
// Sample Function, Uncomment to use
// base.functionName = function(paramaters){
//
// };
+ base.displayNoResults = function() {
+ base.options.listeners.trigger("Indextank.AjaxSearch.noResults", base.el.value);
+ }
+
// gets a copy of the default query.
base.getDefaultQuery = function() {
return base.defaultQuery.clone();
@@ -26,7 +26,7 @@
query.withQueryString(suggestions[0]);
// run it
base.$el.trigger( "Indextank.AjaxSearch.runQuery", query );
- }
+ } else { base.$el.trigger( "Indextank.AjaxSearch.displayNoResults" ); }
});
// make autocomplete focus trigger an AjaxSearch, only if requested
@@ -31,6 +31,10 @@
});
base.$el.css({opacity: 1});
});
+
+ base.$el.bind("Indextank.AjaxSearch.noResults", function(e, query) {
+ base.$el.html("<div class='result'> No results were found for " + query + '.</div>');
+ });
base.$el.bind("Indextank.AjaxSearch.failure", function(e) {
base.$el.css({opacity: 1});

0 comments on commit 43ae187

Please sign in to comment.