Hi friends ,
I was trying this code and finding some errors.I am trying this to
implement dynamic creation of invoice items in invoices using AJAX
.Please go thru .
I added a partial ::
<% @invoiceitem = invoiceitem -%>
<%= text_field ''invoiceitem'',
''item_price'', ''index'' =>
invoiceitem_counter %>
<%= text_field ''invoiceitem'',
''item_qty'', ''index'' =>
invoiceitem_counter
%>
Where are we initialising the counter? Please tell how is the first line
working .
In the rhtml file I have added :
<%= form_remote_tag(:update => "my_list",
:url => { :action => :add_new_item },
:position => "bottom" ) %>
<%= submit_tag "Add New Item" %>
<%= end_form_tag %>
<form action="/ajax/save_items" method="post">
<ul id="my_list">
<li>Original item... please add more!</li>
</ul>
<%= submit_tag ''Update'' %>
</form>
I have added like this for creating a dynamic generation of text boxes
using ajax.
And in the controller class ,
def add_new_item
render(:partial => ''invoiceitems'', :collection =>
@invoice_items)
end
def save_items
@items = []
params[:invoiceitem].each do |key, item|
@items = InvoiceItem.new(item)
end
end
Please help my in implementing this requirement .
Thanks and regards,
Naroor Rathish.
--
Posted via http://www.ruby-forum.com/.