breaks when <script> tag is inside nested_fields block
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 :)
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.
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 :)
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.