如何实现这个嵌套的linked_to_function?

在我看来,我希望用户能够浏览产品目录。 层次结构如下:

Category Product AdditionalInfoForm 

在我的主视图中,我为类别呈现部分:

 #opContent = render :partial => 'op_main_categories' 

op_main_categories partial定义如下:

 - @controller.getPortalCategories.each do |c| = link_to_function "#{c.name}", :class => 'opCategoryHeaderText' do |page| - partial = escape_javascript(render :partial => 'op_secondary_categories', :locals => { :c => c }) - page << "$('opContent').update(\"#{partial}\")" 

当用户单击上面部分中的链接时,产品将通过op_secondary_categories部分呈现:

  - @controller.getPortalProductsForCategory(c).each do |p| = link_to_function "#{p.name}", :class => 'opCategoryHeaderText' do |page| - partial = escape_javascript(render :partial => 'op_did_line', :locals => { :p => p }) - page << "$('opContent').update(\"#{partial}\")" 

op_did_line现在是纯文本:

 %p Yes, this is form! Hello? 

此设置将生成以下链接(对于一个类别):

 <a class="opCategoryHeaderText" onclick="$('opContent').update("<a class=\"opCategoryHeaderText\" href=\"#\" onclick=\"$(\'opContent\').update("

Yes, this is form! Hello?

\n"); return false;\">IPSDN + PVC 3yr\n<a class=\"opCategoryHeaderText\" href=\"#\" onclick=\"$(\'opContent\').update("

Yes, this is form! Hello?

\n"); return false;\">PVC\n"); return false;" href="#">PVC

添加第二层link_to_function会破坏所有代码。 我无法再浏览层次结构。 当只有一个link_to_function存在时,我可以浏览。

该项目仍在使用Rails 2.3。 有什么更好的方法来实现它?

我的问题是使用page中的答案解决的.insert_html不会通过“Jose” 插入带有link_to_function(rails)的html

答案中提供的代码放在rails / lib / rails_ext.rb中