Hi all,

1. After searching for a way to set the input type of a submit tag to
image when using submit_to_remote I realized that the method call
given below, while seemingly valid, wasn't working since the method
button_to_function in
actionpack/lib/action_view/helpers/javascript_helper.rb was forcing
the type to button.

The method call in the view:
<%=
   submit_to_remote(
     'update_resource_img',
     'Update Resource 2',
     :url => { :controller => 'hello', :action => 'update' },
     :before => "$('loading').style.display = 'block'",
     :after => "return false",
     :html => { :src => '/images/button.gif', :type => 'image' }
   )
%>

The output html (Note that the type attribute is set as button):
<input name="update_resource_img" onclick="$('loading').style.display
= 'block'; new Ajax.Request('/hello/update', {asynchronous:true,
evalScripts:true, parameters:Form.serialize(this.form) +
'&amp;authenticity_token=' +
encodeURIComponent('FgOlW7acKtWsvqF6QLQ1CV8Pf8MFHh8EgX8AxyJMsqc=')});
return false;" src="/images/button.gif" type="button" value="Update
Resource 2" />

2. def button_to_function in action_view/helpers/javascript_helper.rb
does the following(note the :type => 'button') :

tag(:input, html_options.merge(:type => 'button', :value => name,
:onclick => onclick))

3. It is my opinion that the def button_to_remote should allow the
input type to be either a button or an image since the w3c page on
form input control types states that the input type image "Creates a
graphical submit button."
http://www.w3.org/TR/html401/interact/forms.html#h-17.4.1

4. Hence, I have submitted a patch(includes associated test cases)
that modifies the line of code listed in point 2 above as:

html_options[:type] = 'button' if( !html_options[:type] ||
html_options[:type] !~ /^image|button$/i )
tag(:input, html_options.merge(:value => name, :onclick => onclick))

5. I would find any feedback/opinion about this issue from this group
very interesting :-)

Thanks,
Gautam
Programmer @ Azri

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to