Bind a temporary list


#1

I’m trying to figure out how to implement a form with a dynamic number of form input fields in the most ‘Meteoric’ way. Basically I have a form which I want to have a dynamic number of e-mail address input fields which can be added to or removed from using +/- buttons on the form.

The path I’ve started down uses a reactive list variable I store on the template which just contain an empty list to start with. In the template, I use {{#each}} to iterate over this reactive list and push new entries to it when the + key is clicked (which seems to update the form accordingly).

What I can’t figure out is if there’s a good way to bind the value of the form input fields such that the reactive list will be updated automatically. So I end up needing jQuery in the end to scrape the form input values and do the final send.

Is there a better way to accomplish this without relying on jQuery to do the final scraping of the form fields?


#2

You need to use a reactive array of some sort and then just let Blaze handle things. Here’s my version of a reactive array:

http://reactivearray.meteor.com/

See the list example.