In my opinion, I want the user to be able to browse the product catalog. The hierarchy is as follows:
Category
Product
AdditionalInfoForm
In my main view, I am doing partial for categories:
#opContent
= render :partial => 'op_main_categories'
The partial parameter op_main_categories is defined as follows:
- @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}\")"
When a user clicks on the partial link above, the products are displayed using the partial part of 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 is plain text:
%p Yes, this is form! Hello?
This setting will create the following link (for one category):
<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>
Adding a second level link_to_function breaks the whole code. I can no longer view the hierarchy. When there is only one link, I can browse.
This project is still using Rails 2.3. What is the best way to implement this?