nathanvda/cocoon — pull request #175 by yoavmatchulsky (2013-10-24 14:13:27+00:00)
Title: Add multiple items on one click

I've added the option of a **count** parameter in `#link_to_add_association` helper.
When this is a valid integer, every click on the Add button will create that number of items.

Most of the code is in javascript of course.
I also cleaned the code a little (`newcontent_braced`, `newcontent_underscord` and `create_new_id` functions)

Example that uses a select tag to dynamically change the count (sort of the case in my app):

Markup (Haml):
```
.add-task-items
= link_to_add_association 'Add', f, :association
%select
%option 1
%option 3
%option 5
```

Code (JS):
```
$('.add-task-items').on('change', 'select', function({
count = $(this).val();
$(this).closest('.add-task-items').find('.add_fields').data('count', count);
});
```

p.s. great gem! :+1: