nathanvda/cocoon

Randomly auto send form after pressing on "link_to_add_association"

anko20094 opened this issue · 2 comments

Cocoon_bug_eng.mp4

When I click on "link_to_add_association" it sometimes send form instead to add new nested form...
_form.html.slim

= link_to_add_association 'Add product', f, :products, 'data-association-insertion-method': :after
      #products
        = f.simple_fields_for :products do |product|
          = render 'product_fields', f: product
    = f.error_notification

Thanks for including the recording to clarify the bug.

However, without more code I fail to see why this behaviour would be caused by the link_to_add_association link.

In general I am trying to understand why the "link" would suddenly behave to post the form. The only explanation i can think of now is that your link is inside a button, if then the javascript is disabled for some reason (an error?), clicking the button would submit the form. However, from the little code you showed that does not seem to be the case.

I am guessing you have some callbacks to manipulate the inserted piece of view, could they be the cause of this?

Can you show more code?

https://user-images.githubusercontent.com/31440971/191706701-8b36dc34-5f80-45b8-9c69-59424b5a3939.mp4
@nathanvda
Thank you very much! Indeed problem was due tag 'Button'. When I separated it, cocoon works perfect
image