【问题标题】:Meteor - Blaze easy-search template - how to insert input field attributes into template?Meteor - Blaze 轻松搜索模板 - 如何将输入字段属性插入模板?
【发布时间】:2018-08-17 14:46:30
【问题描述】:

所以我有一个易于搜索的模板:

<template name="searchBox">

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

</template>

我想让输入字段看起来像这样(具有以下属性):

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

我尝试将属性添加到参数中,但这似乎不起作用:

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

任何想法如何实现这一目标?

【问题讨论】:

    标签: meteor meteor-blaze meteor-easy-search


    【解决方案1】:

    只需在您的 HTML 中添加 attributes 属性:

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

    在你的 JS 中,用你需要的数据填充它:

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

    我可以通过查看 repo 找到答案,因此请务必查看 github 存储库,因为它们可能包含有用的示例。 ;)

    【讨论】:

      猜你喜欢
      • 2019-02-02
      • 1970-01-01
      • 2021-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-21
      相关资源
      最近更新 更多