On Apr 12, 2:55 pm, Jack Yang <[email protected]>
wrote:
> I have a form with two submit buttons: "Save" and "Preview". In my
> controller for this form, I do different things based on
> params[:commit]. But somehow the params[:commit] always evals "Save",
> even when I click Preview button. Why? any idea will be appreciated.

Because you've got an ajax form. The javascript that serializes the
form for you doesn't know which submit was clicked (unlike the browser
code that would run with a normal form), and so it will have the
commit parameter in twice (once with each value) and rails will
discard one of them. You could probably use submit_to_remote with an
appropriate
:with option to do this.

Fred


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to