【问题标题】:How to store the value of a column from each row of a list into a collection using Meteor?如何使用 Meteor 将列表每一行中的列值存储到集合中?
【发布时间】:2015-02-25 21:46:57
【问题描述】:

我有一个单列表格,表格的每个条目都是一个文本区域。用户在多行中填写文本区域后,我想通过单击按钮将每个文本区域的数据存储在集合中。我怎样才能在 Meteor 中做到这一点? HTML 模板如下所示:

<table id="myTable" class="table table-bordered">
                <thead>
                    <tr>
                        <th>Notes</th>
                    </tr>
                </thead>
                <tbody>
                    {{#each items}}
                    <tr>
                        <td id="notes">
                            <textarea rows="4" cols="50">
                            </textarea>
                        </td>
                    </tr>
                    {{/each}
                </tbody>
</table>

【问题讨论】:

    标签: javascript meteor


    【解决方案1】:

    你可以尝试使用JQuery的.each方法。

    例子:

    Template.yourtemplate.events({
        'click .button': function(e) {
            $("textarea").each(function(i) {
                YourCollection.insert($(this).val())
            })
        }
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 2015-02-01
      • 2021-09-02
      • 2020-07-28
      • 2013-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多