Deep Arora
Deep Arora

Reputation: 2040

How to store the value of a column from each row of a list into a collection using Meteor?

I have a single column table and each entry of the table is a text area. After user fills out the text area in multiple rows, I want to store the data of each text area in a collection on click of a button. How can I do this in Meteor? The HTML template looks like this:

<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>

Upvotes: 0

Views: 56

Answers (1)

wtfzn
wtfzn

Reputation: 538

You could try to utilize the .each Method of JQuery.

Example:

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

Upvotes: 2

Related Questions