我将 rails 应用程序从 rails 升级2.3.14
到 rails 3.2.6
。link_to_function 没有生成正确的 html。
以下辅助方法。. .
link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")"))
正在生成...
<a href="#" onclick="add_fields(this, &quot;quick_facts&quot;, &quot;&lt;div class=\'quick_fact\'&gt;\n &lt;div class=\'grid_4 prefix_1\'&gt;\n &lt;label for=\&quot;organization_quick_facts_attributes_new_quick_facts_quick_fact\&quot;&gt;QuickFact&lt;\/label&gt;\n &lt;br&gt;\n &lt;select class=\&quot;quick_fact_select\&quot; id=\&quot;organization_quick_facts_attributes_new_quick_facts_quick_fact\&quot; name=\&quot;organization[quick_facts_attributes][new_quick_facts][quick_fact]\&quot;&gt;&lt;option value=\&quot;\&quot;&gt;&lt;\/option&gt;\n &lt;option value=\&quot;Hours\&quot;&gt;Hours&lt;\/option&gt;\n &lt;option value=\&quot;Serving\&quot;&gt;Serving&lt;\/option&gt;\n &lt;option value=\&quot;Insurance Accepted\&quot;&gt;Insurance Accepted&lt;\/option&gt;\n &lt;option value=\&quot;Features\&quot;&gt;Features&lt;\/option&gt;\n &lt;option value=\&quot;Services Provided\&quot;&gt;Services Provided&lt;\/option&gt;&lt;\/select&gt;\n &lt;br&gt;\n &lt;\/div&gt;\n &lt;div class=\'clear\'&gt;&lt;\/div&gt;\n &lt;div class=\'grid_4 prefix_1\'&gt;\n &lt;label for=\&quot;organization_quick_facts_attributes_new_quick_facts_content\&quot;&gt;Content&lt;\/label&gt;\n &lt;br&gt;\n &lt;input id=\&quot;organization_quick_facts_attributes_new_quick_facts_content\&quot; maxlength=\&quot;200\&quot; name=\&quot;organization[quick_facts_attributes][new_quick_facts][content]\&quot; size=\&quot;200\&quot; type=\&quot;text\&quot; /&gt;\n &lt;br&gt;\n &lt;\/div&gt;\n &lt;div class=\'clear\'&gt;&lt;\/div&gt;\n &lt;div class=\'grid_2 prefix_1 exempt\'&gt;\n &amp;nbsp;\n &lt;a href=\&quot;#\&quot; class=\&quot;remove_temp_qf\&quot;&gt;remove&lt;\/a&gt;\n &lt;\/div&gt;\n&lt;\/div&gt;\n&quot;); return false;">Add Another QuickFact</a>
呈现此 html 时,未调用 onclick 函数,这是错误。
syntax error
add_fields(this, "quick_facts", "<div class=\'quick_fact\'>...
quick_facts# (line 1, col 17)
有什么办法解决这个问题吗??