Starting a simple meteor app to search a database and running into some issues. I have an input box where the search query is obtained using the code below:
Template.search.events = {
'keydown input#search' : function (event) {
if (event.which == 13) {
var item = document.getElementById('search');
Template.results.results(item.value)
//console.log(item);
item.value = '';
}
}
}
The search query is then passed to another function which queries the mongodb to print the result in the template:
Template.results.results = function (item) {
return Products.find({sku: item});
}
However, it doesn't seem to find the item! When running the same query in Chrome's console or using a hardcoded value like {sku: "A2277"} it works fine. Even creating a new variable with a hardcoded value within the Template.results.results function works. What could be causing this issue?