I''m wanting to implement a way to preview a comment on my site. I''m currently using ajax to save the comments now, so in order to do the preview, I basically want to do the same thing without saving. That''s no big deal. Now, the place where I run into problems, is there is only one "form_remote_tag" and two buttons. How to do I set things up for one to call the "comments" action and for the other to call "comments_preview" action from within one form? Or am I thinking about this all wrong? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
A nice way of doing previews is to have them dynamically update, see observe_field for this. You can also use link_to_remote with a ":with" parameter and pass the content of your form (Form.serialize): <%= link_to_remote "Preview", :update=>''preview_panel'', :url=>{ :action=>''preview'' }, :with=>"Form.serialize(''form_id'')" %> Max On 8/25/06, ry an <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m wanting to implement a way to preview a comment on my site. I''m > currently using ajax to save the comments now, so in order to do the > preview, I basically want to do the same thing without saving. That''s > no big deal. > > Now, the place where I run into problems, is there is only one > "form_remote_tag" and two buttons. How to do I set things up for one to > call the "comments" action and for the other to call "comments_preview" > action from within one form? > > Or am I thinking about this all wrong? Thanks! > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
prototype''s Form.serialize doesn''t handle submit buttons very well, in that submit buttons, no matter how many get serialized, no matter if they are named the same or not. so for example, you would get name=Bob action=save action=preview so what i would suggest, is you detach the buttons from the form, perhaps making them button elements and create 2 javascript functions, one to submit the comment for preview and one to submit the comment for saving, and then attach to each button via onclick. each function would then submit to a different controller/action to handle accordingly. On 8/24/06, ry an <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m wanting to implement a way to preview a comment on my site. I''m > currently using ajax to save the comments now, so in order to do the > preview, I basically want to do the same thing without saving. That''s > no big deal. > > Now, the place where I run into problems, is there is only one > "form_remote_tag" and two buttons. How to do I set things up for one to > call the "comments" action and for the other to call "comments_preview" > action from within one form? > > Or am I thinking about this all wrong? Thanks! > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---