awesome_nested_fields icon indicating copy to clipboard operation
awesome_nested_fields copied to clipboard

Only 2 items get inserted while inserting 4

Open rept opened this issue 12 years ago • 4 comments

I have downloaded and ran the demo of multi_level.

When I insert a task with 4 resources like this:

Step1

If I then click save I see this:

Step2

So only the first and last resource get created.

rept avatar Jan 31 '13 01:01 rept

BTW I noticed this in the docs:

new_item_index: 'new_resource_index' // Same used on view options

but in the view there is

<%= f.nested_fields_for :resources, new_item_index: 'new_resource_item', html: { class: "resource-form" } do |f| %>

Is that correct? So new_resource_index != new_resource_item

Maybe that has something to do with it.

rept avatar Jan 31 '13 01:01 rept

I think this project is out of date. I'm updating it now.

lailsonbm avatar Feb 03 '13 19:02 lailsonbm

Hi lailsonbm,

This is the project I'm talking about where it's only inserting the last and first item. Should I create an issue there or do you think it's in the code of the gem?

rept avatar Feb 04 '13 23:02 rept

I'm seeing a problem similar to this as well.

Im creating X number of nested forms using this JS function.

element.nestedFields('insert', function(item) { // Make some operation with item }, {skipBefore: true});

The correct number of extra forms are shown in the clientside, but when I submit the form, only some of the records are actually saved.

If I create each field manually using a "+ Add Phone" trigger button it seems to work OK

But for example if I create 10 extra fields via the insert JS function and pre-fill the values in them using JS, only a few of them will actually save, commonly around 4 or 5.

If you need help recreating this I can give you more detail. I'm not sure where to start on debugging this as I can't lock down the exact criteria of the bug, I think it's related to creating multiple fields at once using the insert function.

thanks for your help. George

georgecoltart avatar Jul 10 '13 09:07 georgecoltart