0

Here is a simple example of the problem.

http://gist.github.com/235729

In short, if you have a index.rhtml with:

<%= 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 %>

And a _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 %>

It breaks the "A link to insert a partial with nested insert_html". I am thinking something needs to be done to protect the javascript in the partial.

Any thoughts?

3 Answers 3

1

Here's how I do it.

<%= 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 %>
Sign up to request clarification or add additional context in comments.

Comments

0

Try using escape_javascript before rendering the partials - see this other question.

Comments

0

I didn't try but I strongly think the syntax should be more something like :

<% 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 %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.