Ruby on Rails: image_submit_tag and :confirm

I was told about an issue today with the image_submit_tag not supporting the :confirm method on the element:

<%= image_submit_tag('buttons/submit.gif', { :confirm => 'Are you sure?' }) %>

so I thought I’d share a quick fix which would be the actual javascript returned by the function:

<%= image_submit_tag('buttons/submit.gif', { :onclick => 'return
confirm(\'Are you sure?\');' }) %>

Hope this can save some people time…

2 Replies to “Ruby on Rails: image_submit_tag and :confirm”

    1. Hi Ashok,

      By the sounds of it, you’re using Firefox, which automatically displays the url of the site in any alert/confirm javascript box. I guess it’s for security, so you can tell the message box is coming from the site you think it is… I’m not sure if there any way to get around that, short of writing your own alert/confirm system…

      Sorry!

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.