This line of the JS removes any outside whitespace:
searchString = searchString.replace(/^\s+|\s+$/, '');
However, that comes after these two lines:
var db = this;
this.searchString = searchString;
If you include a space, it correctly strips out the outside whitespace and then runs the search and gets the results. But, upon display of the results, this check is evaluated:
// Verify if these are still the matches the user wants to see.
if (db.searchString == searchString) {
As currently defined, the user input and db.searchString is "word " (with a space) and the search that was submitted was just "word" (without a space). So in this If db.searchString and searchString do not match. In other words, "word " is submitted, the space is stripped and the AJAX does a query or cache call for "word", but then after all that does not display the result.
My solution was to make line 12, where the outside whitespace is stripped, as follows:
this.searchString = searchString = searchString.replace(/^\s+|\s+$/, '');
In this way, the whitespace is trimmed and the search (minus whitespace) is displayed to the user.