Quantcast
Channel: Pragmatic Forums | Posts by Tan YL
Viewing all articles
Browse latest Browse all 19

highlight effect posted by Tan YL @ Tue, 02 Sep 2008 16:07:09 +0000

$
0
0

Hi,

I have been trying to add the highlight effect to my table but everytime a new record is added the highlighting gives an rjs error. is this because the partial must only have only one <tr></tr> in it and the <table> must be on the other page that is rendering that partial?

View Code:
-------
<table>
<% for product in @lineprice %>

<% if product.groceries.id == @item.groceries_id %>
   <tr id="highlighted"><% else %>
   <tr><% end %>
      <td><%= product.groceries.brand %></td><td><%= product.groceries.name %></td><td><%= product.quantity %></td><td><= qx(product,"c") %>< totalC += qx(product,"c")%></td><td><= qx(product,"n") %>< totalN += qx(product,"n") %></td><td><= qx(product,"s") %>< totalS += qx(product,"s") %></td><td><= qx(product,"g") %>< totalG += qx(product,"g") %></td><td><= qx(product,"ca") %>< totalCa += qx(product,"c") %></td><td>item:<= @item.groceries_id>Product:<%= product.groceries.id %></td><td><= cheapest=product.groceries.supermarket.attributes.except('id', 'groceries_id','created_at','updated_at').values.min %> <= Groceries.namecompare2(product) >< totalCh += cheapest %></td></tr><% end %>
<table>
-------------------------

Form Code:


<% form_remote_tag :url => {:controller => “sgpanel”, :action => “add_to_cart”, :ad => params[:id] , :bd => groceries.id } do %>

<= submit_tag “Add to Cart” %>
<
end %>

---------
Controller Code:

def add_to_cart @sguser = Sguser.find(params[:ad]) @lineprice = SglineItem.find(:all, :conditions => “sguser_id = #{params[:ad]}”)

if SglineItem.find(:first, :conditions => ['sguser_id =? and groceries_id =?', params[:ad], params[:bd]])== nil
@item = SglineItem.new
@item.sguser_id= params[:ad]
@item.groceries_id=params[:bd]
@item.save!
else
@item = SglineItem.find(:first, :conditions => ['sguser_id =? and groceries_id =?', params[:ad], params[:bd]])
@item.quantity +=1
@item.save!
end
respond_to do |format|
format.js 
end
end
-----------------------------

Js.rjs code:

page.replace_html ‘calculated’, :partial => ‘add_to_cart’
page[:highlighted].visual_effect :highlight,:startcolor => ”#88ff88” ,:endcolor => ”#FFFFFF”


Viewing all articles
Browse latest Browse all 19

Trending Articles