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

breaks when <script> tag is inside nested_fields block #46

Open
asgerb opened this issue Aug 12, 2015 · 3 comments
Open

breaks when <script> tag is inside nested_fields block #46

asgerb opened this issue Aug 12, 2015 · 3 comments

Comments

@asgerb
Copy link

asgerb commented Aug 12, 2015

I'm using an input which appends a script tag to the input. This breaks the nested_fields <script> tag and the view.

It should be super easy to reproduce the bug, simply add a script tag to the nested_fields block, but I can provide example code if necessary :)

@ncri
Copy link
Owner

ncri commented Aug 13, 2015

Using script tags inside nested fields breaks, because nested_form_fields uses script tags to store the nested fields blueprints/templates. Nesting script tags within script tags breaks the html. See also the comment here in line 84: https://github.com/ncri/nested_form_fields/blob/master/lib/nested_form_fields.rb It's a bit tricky.

Using inline js is not the best coding style anyway. Better use an external js file and the callbacks nested_form_fields provides.

@asgerb
Copy link
Author

asgerb commented Aug 13, 2015

That’s what I figured. The reason for having inline js is accidentally the same reason nested_form_fields has inline js: to store a template (https://github.com/tomasc/simple_form_attachments).

But yeah that’s a bit tricky. How about escaping the html? Quite hackish I guess :)

@ncri
Copy link
Owner

ncri commented Aug 13, 2015

Ah, that is unfortunate. I might try to make script tags work inside nested fields when I have some time, but so far it's a limitation of gem. Feel free to hack the js, it is not much code but hacking it is tricky because nested_form_fields supports deep nesting.

In fact the whole gem is a bit of a hack. Ideally we should use the html5 template tag instead of script tags I guess. But that is not supported in IE/Edge.

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