Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nested form with JS call is impossible in a clean way #431

Open
Antronin opened this issue Jun 13, 2017 · 2 comments
Open

Add nested form with JS call is impossible in a clean way #431

Antronin opened this issue Jun 13, 2017 · 2 comments

Comments

@Antronin
Copy link

Hi!

I really like the gem, but currently it seems impossible to trigger the insertion of the nested form from JS. Of course I can trigger the click event on the button from JS but that will not give me the inserted fields list back, and it has anyway a bad code smell.
Can you maybe merge #290 pullrequest? I would give a muchcleaner JS API to cocoon.

@Antronin Antronin changed the title Add nested form with JS call is impossible Add nested form with JS call is impossible in a clean way Jun 13, 2017
@nathanvda
Copy link
Owner

The pullrequest you mentioned is dependant on jquery ui. I prefer not to introduce that dependency.

I understand that triggering insertion from javascript is at the moment not optimal. Could you explain your use-case?

@Antronin
Copy link
Author

Hi!
The use case: I have an image where I can select (via mous selection) multiple areas and I'm storing the coordinates in nested form fields. When I add a new fieldset via cocoon, I can create a selection on the image using the after-create callback.
But I can do it in the opposite way: I make aselection on the image which should result in the creation of a nested form set with the coordinates of the selection in them.
This later part is problematic, because there is no way of initiate the field set creation through JS. The only way I can think of is triggering the "click" event on the button, but that will trigger the after-create event too, which will duplicate my original selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants