Submit_to_remote with image

Anyone have an idea how I can shoehorn (or workaround) a
submit_to_remote to accept html options so that I might put an image
to it?

Hi Janna,

On Thu, 2009-07-09 at 08:44 -0700, JannaB wrote:

Anyone have an idea how I can shoehorn (or workaround) a
submit_to_remote to accept html options so that I might put an image
to it?

link_to_remote takes an image_tag in place of the name text and
the :submit option.

image_submit_tag will give you a straight HTTP submit with an image
instead of a button.

HTH,
Bill

Janna,

image_submit_tag has a nasty effect of not applying rollover but I got
it to work by calling javascript directly:

<%= image_submit_tag(’/images/your_main_image.jpg’,
:title => “Search”,
:class => “btnsearch”,
:onmouseover =>
“this.src=’/images/your_rollover_image.jpg’”,
:onmouseout => “this.src=’/images/your_main_image.jpg’”) %>

On Jul 9, 4:44 pm, JannaB [email protected] wrote:

Anyone have an idea how I can shoehorn (or workaround) a
submit_to_remote to accept html options so that I might put an image
to it?

if you do submit_to_remote blah, blah, :html => {…}

then that options hash is passed to button_to_remote (and thus
button_to_function etc.)

Fred

Ok, but I cannot have a submit_to_remote with an image, right?

Fred,

I thnk you may be wrong on this (for once!) -or-, more likely, I cant
find the right hash key for the image (I’m unable to discern the
correct syntax).
For example, the following works, but, my problem is that it doesn’t
pick up the values of other controls on the form:

<%= link_to_remote image_tag("/images/icecube.gif"), {:url =>{:action
=> ‘freezer’}} %>

when I follow what (I think) you have suggested:

<%= submit_to_remote ‘Freezer’, ‘freezer’, {:url => { :action =>
‘freezer’ }, :name => image_tag("/images/icecube.gif")} %>

doesn;t pick up the image. But The hash key may be something other
than ‘name’ (I have tried, ‘image,’ and ‘img’ but I dont see how this
would map to the name parameter in link_to_remote) -Janna B

Hello–

On Jul 9, 2009, at 8:44 AM, JannaB wrote:

Anyone have an idea how I can shoehorn (or workaround) a
submit_to_remote to accept html options so that I might put an image
to it?

It looks, from some of your recent posts, that the Javascript helpers
may be more of an impediment than a help to you. The JS helpers work
great for the things they were designed to do. Many people prefer
simply to use Prototype or jQuery without any Rails magic. It’s not
much harder and you your own code almost always bends to your will.

Just a thought.

On Jul 9, 8:57 pm, JannaB [email protected] wrote:

when I follow what (I think) you have suggested:

<%= submit_to_remote ‘Freezer’, ‘freezer’, {:url => { :action =>
‘freezer’ }, :name => image_tag("/images/icecube.gif")} %>

That wasn’t what I was getting at.
if you do submit_to_remote ‘Freezer’, ‘freezer’, :url => { :action =>
‘freezer’ }, :html => {…}
then that will set html options on the input element that is
generated.

Fred

I wanted to something similar and ended up monkey-patching
JavaScriptHelper …
http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/244e24285d3d883d

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs