Search code examples
meteormeteor-blazemeteor-easy-search

Meteor - Blaze easy-search template - how to insert input field attributes into template?


So I have an easy-search template:

<template name="searchBox">

    <div class="">
        {{> EasySearch.Autosuggest index=PlayersIndex }}
    </div>

</template>

And I'd like to make the input field look like this (have the following attributes):

          <input
            type="text"
            placeholder="Type to add new player"
            ref="textInput"
          />

I've tried adding the attributes to the argument but that doesn't seem to work:

        {{> EasySearch.Autosuggest index=PlayersIndex type="text"}}

Any ideas how to achieve this?


Solution

  • Just add attributes property in your HTML:

    {{> EasySearch.Input index=index attributes=inputAttributes}}
    

    And in your JS, fill it with your needed data:

    `Template.leaderboard.helpers({
        inputAttributes: function () {
            return { 'class': 'easy-search-input', 'placeholder': 'Start searching...' };
        }
    )}
    `
    

    I was able to find the answer by looking at this repo, so make sure to check github repos as they might contain helpful examples. ;)