When i use button_to or link_to, i can easily request a confirmation dialog with (for example) <%= button_to "Delete this story", { :controller => "story", :action => "delete", :id => @story.id }, :confirm => "Delete story: are you sure?" %> I also want to do this for the submit buttons on my forms, which are "submit_tag" rather than "button_to". But it doesn''t seem to be possible, looking at the submit_tag source or trying it in my code (unless i''m just being dumb). Can anyone explain how i can do this please? 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?hl=en -~----------~----~----~----~------~----~------~--~---
<%= submit_tag(''Delete checked articles'', :onclick => "return confirm(''Are you sure you want to delete this article?'')") %> Adam On 9/4/07, Max Williams <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > When i use button_to or link_to, i can easily request a confirmation > dialog with (for example) > > <%= button_to "Delete this story", > { :controller => "story", :action => "delete", :id => @story.id }, > :confirm => "Delete story: are you sure?" %> > > I also want to do this for the submit buttons on my forms, which are > "submit_tag" rather than "button_to". But it doesn''t seem to be > possible, looking at the submit_tag source or trying it in my code > (unless i''m just being dumb). > > Can anyone explain how i can do this please? > > 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?hl=en -~----------~----~----~----~------~----~------~--~---
Max Williams
2007-Sep-05 08:57 UTC
Re: How can i add a confirmation dialog to a submit_tag?
Adam Cohen wrote:> <%= submit_tag(''Delete checked articles'', :onclick => "return > confirm(''Are you sure you want to delete this article?'')") %> > > AdamThanks adam, but i couldn''t get this to work. Someone else suggested a variation that does work fine though: <%= submit_tag "Submit Reeply", :onclick => "return #{confirm_javascript_function("Are you sure?")}" %> thanks, max -- 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?hl=en -~----------~----~----~----~------~----~------~--~---