matteodem / meteor-easy-search

Easy-to-use search for Meteor with Blaze Components
MIT License
435 stars 68 forks source link

populating easy search input and getting search results on page render #651

Closed meecect closed 3 years ago

meecect commented 4 years ago

When entering a new route (with flowrouter), is it possible to prepopulate the easysearch.index component with a search term and execute the results so that easysearch.each will have results to show?

In this case I am getting the search term in a url param (/search/[terms]) so i wan the page to show the search input with [terms] and the initial results below it.

I know I can get the mongoCursor from the index in a helper function...is that the way to do this? What is the appropriate way of setting the value of the search input, short of just using $().val() ?

thanks, Cliff

matteodem commented 4 years ago

Does following do the trick?

index.getComponentMethods(/** name if needed **/).search('searchvalue')

See https://matteodem.github.io/meteor-easy-search/docs/components/ (Using component methods)