无法在脚本标记内部渲染Rails

时间:2023-01-16 09:43:56

I'm trying to execute this:

我正在尝试执行此操作:

<script type="text/javascript">
    <%= render( :partial => "shared/editor_link_js", locals: { editor: @editor }) %>
</script>

However this throws an error telling me that the partial editor_link_js is missing.

但是,这会抛出一个错误,告诉我部分editor_link_js丢失了。

But if i run this alone:

但如果我独自运行:

<%= render( :partial => "shared/editor_link_js", locals: { editor: @editor }) %>

I find the partial. Does any one know what causes this and how to avoid it?

我找到了局部的。有没有人知道是什么导致这种情况以及如何避免它?

1 个解决方案

#1


0  

you have to do something like this

你必须做这样的事情

<script type="text/javascript">
    $("#div").html('#{escape_javascript(render(:partial => "shared/editor_link_js", locals: { editor: @editor })}');
</script>

#1


0  

you have to do something like this

你必须做这样的事情

<script type="text/javascript">
    $("#div").html('#{escape_javascript(render(:partial => "shared/editor_link_js", locals: { editor: @editor })}');
</script>