0

問題の簡単な例を次に示します。

http://gist.github.com/235729

つまり、次の index.rhtml があるとします。

<%= link_to_function "A link to insert a partial with nested insert_html" do |page|
      page.insert_html :top, :with_a_nested_insert_html, :partial => 'example_partial_with_nested_insert_html'
    end %>

そして _example_partial_with_nested_insert_html.rhtml

<%= link_to_function "A nested link to insert_html" do |page|
      page.insert_html :top, :with_a_nested_insert_html, :partial => 'you_wont_see_this'
    end %>

「ネストされたinsert_htmlを使用してパーシャルを挿入するリンク」を壊します。部分的にJavaScriptを保護するために何かをする必要があると考えています。

何かご意見は?

4

3 に答える 3

1

これが私のやり方です。

<%= link_to_function( "insert it", :id => 'foo') do |page| 
            partial = escape_javascript(render :partial => "my_partial", :object => Object.new)
            page <<  "$('#my_div').append(\"#{partial}\")"
        end %>
于 2010-01-28T23:45:31.150 に答える
0

パーシャルをレンダリングする前にescape_javascriptを使用してみてください-この他の質問を参照してください

于 2009-11-16T10:08:27.493 に答える
0

私は試しませんでしたが、構文は次のようなものにすべきだと強く思います。

<% link_to_function "A link to insert a partial with nested insert_html" do |page|
   <%= page.insert_html :top, :with_a_nested_insert_html, :partial => 'example_partial_with_nested_insert_html' %>
<% end %>
于 2009-11-16T06:49:40.193 に答える