0
如果有人能幫我解決以下問題,我將不勝感激。將參數傳遞給rjs文件
我有以下形式:
new_book形式
<% remote_form_for @book, :url => { :controller => "books", :action => "create_sub_book"} do |f| %>
<%= f.text_field :book_name %>
<%= f.text_field :book_publication %>
<%= params[:id] %> <!-- I need to pass this value to create_sub_book action, which will then pass it to create_sub_book.js.rjs -->
<p><%= f.submit 'Create'%></p>
<% end %>
* 控制器動作*
def create_sub_book
@book = book.new(params[:book])
respond_to do |format|
if @book.save
format.js
else
flash[:notice] = "Book failed to save."
end
end
end
** ** create_sub_book.js.rjs
`page.alert(params[:id]) ## On this page I need to access the params[:id] on the 'new_book' form. This line does not work`.
有關如何將'new_book'表單上的params [:id]傳遞給'create_sub_book.js.rjs'的任何建議?
感謝您的幫助
明白了,非常感謝你 – Kim 2012-07-05 14:00:34