I am trying to implement a search in my Meteor application. I do not quite understand how this is connected. At this point, I have the following code:
HTML:
<form class="navbar-search pull-left"> <input type="text" class="search-query" placeholder="Search"> </form>
JS:
Template.menubar.events({ 'keyup input.search-query': function (evt) { console.log("Keyup value: " + evt.which); if (evt.which === 13) { console.log("Got an Enter keyup"); Session.set("searchQuery", "justATestVar"); } } });
I can see the keyup values ββwhen I press different keys in the search field, so I know that the event hit. Capturing the enter key also works, but pressing enter forces the site to load, and when I do this:
Session.get("searchQuery")
it returns undefined.
I do not know if I am doing this correctly. Essentially, I just want to get the value from the search box, and then use that value to search in my collection. Any help would be appreciated! Thanks.
source share