0
在我看來,我希望用戶能夠瀏覽產品目錄。層次結構是如下:如何實現這個嵌套的linked_to_function?
Category
Product
AdditionalInfoForm
以我主視圖我渲染的部分爲類:
#opContent
= render :partial => 'op_main_categories'
的op_main_categories部分被定義如下:
- @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("<p>Yes, this is form! Hello?</p>\n"); return false;\">IPSDN + PVC 3yr<\/a>\n<a class=\"opCategoryHeaderText\" href=\"#\" onclick=\"$(\'opContent\').update("<p>Yes, this is form! Hello?</p>\n"); return false;\">PVC<\/a>\n"); return false;" href="#">PVC</a>
添加link_to_function的第二層打破了所有的代碼。我不再能夠瀏覽層次結構。當只有一個link_to_function存在時,我可以瀏覽。
該項目仍在使用Rails 2.3。什麼是更好的實現方式?
是,我的問題得到解決的實際代碼剪切和粘貼?因爲我看到語法錯誤。發佈實際的代碼會有所幫助。以及張貼錯誤你得到。 – 2013-05-03 15:41:18
'.replaceWidth()'不是PrototypeJS方法 - 它應該是'.replace()' – 2013-05-03 17:57:14