Highlighint rjs problem on a new product

Hi,

Problem Summary:

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.
However when i click the add to cart button on a product that already
exists inside the table, the highlight effect works. Is this because
the partial must only have only one

in it and the
must be on the other page that is rendering that partial?

View Code:

<% for product in @lineprice %>

<% if product.groceries.id == @item.groceries_id %>

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

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

No need help anymore solved!

I think i am nearer to the problem. it looks like the controller
add_to_cart function cannot save a new item and display it
correspondingly into the ajax parital.

I tried doing this

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

@item = SglineItem.new
@item.sguser_id= params[:ad]
@item.groceries_id=params[:bd]
@item.save!


respond_to do |format|
format.js
end

end

and the ajax partial would not update itself