2009-11-16 5 views
0

다음은 간단한 문제의 예입니다. 한마디로중첩 된 link_to_function/insert_html이 작동하지 않습니다.

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

그것은 부분을 삽입하는 "A 링크를 나누기를 중첩 된 insert_html ". 나는 뭔가를 자바 스크립트를 부분적으로 보호하기 위해해야한다고 생각하고있다.

의견이 있으십니까?

답변

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 %> 
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 %> 
관련 문제