Tom Campbell
2007-Nov-25 05:46 UTC
image_tag is missing "class=" attribute--how can I replace javscript behavior?
(Apologies if a previous message was posted inadvertently. My finger
slipped on the enter key.)
While converting a static HTML prototype to Rails I changed a bunch of
alinks from this:
<a href="find.html"><img
src=''/images/findTab.jpg'' alt="Find"
class="rollover" /></a>
to the more Railsesque construction shown here:
<%= link_to(image_tag(''findTab.jpg'', :alt =>
''Find an item''), :action
=> ''Find'') %>
Sharp-eyed readers will note that the class="rollover" attribute,
which was provided by Javascript, is now gone. While image_tag has
an :alt option in the hash there is no :class option.
How can I restore the class="rollover" attribute if image_tag
doesn''t
support it, or at least get the rollover behavior back somehow?
Thank you.
Tom Campbell
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
William Pratt
2007-Nov-25 05:49 UTC
Re: image_tag is missing "class=" attribute--how can I replace javscript behavior?
link_to takes a third argument that is a hash of html options:
<%= link_to(image_tag(''findTab.jpg'', :alt =>
''Find an item''), {:action=> ''Find''},
:class => ''rollover'') %>
-Bill
Tom Campbell wrote:> (Apologies if a previous message was posted inadvertently. My finger
> slipped on the enter key.)
>
> While converting a static HTML prototype to Rails I changed a bunch of
> alinks from this:
> <a href="find.html"><img
src=''/images/findTab.jpg'' alt="Find"
> class="rollover" /></a>
>
> to the more Railsesque construction shown here:
> <%= link_to(image_tag(''findTab.jpg'', :alt =>
''Find an item''), :action
> => ''Find'') %>
>
> Sharp-eyed readers will note that the class="rollover" attribute,
> which was provided by Javascript, is now gone. While image_tag has
> an :alt option in the hash there is no :class option.
>
> How can I restore the class="rollover" attribute if image_tag
doesn''t
> support it, or at least get the rollover behavior back somehow?
>
> Thank you.
>
> Tom Campbell
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
William Pratt
2007-Nov-25 05:51 UTC
Re: image_tag is missing "class=" attribute--how can I replace javscript behavior?
Oops, I just noticed that you are applying that class to the image not
the link, but this will work:
<%= link_to(image_tag(''findTab.jpg'', :alt =>
''Find an item'', :class => ''rollover''),
:action=> ''Find'') %>
-Bill
William Pratt wrote:> link_to takes a third argument that is a hash of html options:
>
> <%= link_to(image_tag(''findTab.jpg'', :alt =>
''Find an item''), {:action=> ''Find''},
:class => ''rollover'') %>
>
> -Bill
>
> Tom Campbell wrote:
>
>> (Apologies if a previous message was posted inadvertently. My finger
>> slipped on the enter key.)
>>
>> While converting a static HTML prototype to Rails I changed a bunch of
>> alinks from this:
>> <a href="find.html"><img
src=''/images/findTab.jpg'' alt="Find"
>> class="rollover" /></a>
>>
>> to the more Railsesque construction shown here:
>> <%= link_to(image_tag(''findTab.jpg'', :alt =>
''Find an item''), :action
>> => ''Find'') %>
>>
>> Sharp-eyed readers will note that the class="rollover"
attribute,
>> which was provided by Javascript, is now gone. While image_tag has
>> an :alt option in the hash there is no :class option.
>>
>> How can I restore the class="rollover" attribute if image_tag
doesn''t
>> support it, or at least get the rollover behavior back somehow?
>>
>> Thank you.
>>
>> Tom Campbell
>>
>>
>>
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Mark Van Holstyn
2007-Nov-25 05:59 UTC
Re: image_tag is missing "class=" attribute--how can I replace javscript behavior?
On Nov 25, 2007 12:49 AM, William Pratt <billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org> wrote:> > link_to takes a third argument that is a hash of html options: > > <%= link_to(image_tag(''findTab.jpg'', :alt => ''Find an item''), {:action=> > ''Find''}, :class => ''rollover'') %>However, that adds the class to the anchor tag, not the image...> > Sharp-eyed readers will note that the class="rollover" attribute, > > which was provided by Javascript, is now gone. While image_tag has > > an :alt option in the hash there is no :class option. >Actually, any option you pass to image_tag will be in the generated html tag as an attribute: <%= link_to(image_tag(''findTab.jpg'', :alt => ''Find an item'', :class => ''rollover''), :action=> ''Find'') %> Mark -- Mark Van Holstyn, Partner / Software Developer mvanholstyn-y/MygF1AHQSJ0iEMtI82hwC/G2K4zDHf@public.gmane.org, (616) 706-6842 Mutually Human Software, http://mutuallyhuman.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 -~----------~----~----~----~------~----~------~--~---
William Pratt
2007-Nov-25 16:57 UTC
Re: image_tag is missing "class=" attribute--how can I replace javscript behavior?
Right, hence my second post 10 seconds after my first post:> Oops, I just noticed that you are applying that class to the image not > the link, but this will work: > > <%= link_to(image_tag(''findTab.jpg'', :alt => ''Find an item'', :class => ''rollover''), :action=> ''Find'') %> > > -BillMark Van Holstyn wrote:> On Nov 25, 2007 12:49 AM, William Pratt <billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org > <mailto:billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org>> wrote: > > > link_to takes a third argument that is a hash of html options: > > <%= link_to(image_tag(''findTab.jpg'', :alt => ''Find an item''), > {:action=> ''Find''}, :class => ''rollover'') %> > > > However, that adds the class to the anchor tag, not the image... > > > > Sharp-eyed readers will note that the class="rollover" attribute, > > which was provided by Javascript, is now gone. While image_tag has > > an :alt option in the hash there is no :class option. > > > Actually, any option you pass to image_tag will be in the generated > html tag as an attribute: > > <%= link_to(image_tag(''findTab.jpg'', :alt => ''Find an item'', :class => > ''rollover''), :action=> ''Find'') %> > > Mark > > -- > Mark Van Holstyn, Partner / Software Developer > mvanholstyn-y/MygF1AHQSJ0iEMtI82hwC/G2K4zDHf@public.gmane.org <mailto:mvanholstyn-y/MygF1AHQSJ0iEMtI82hwC/G2K4zDHf@public.gmane.org>, > (616) 706-6842 > Mutually Human Software, http://mutuallyhuman.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 -~----------~----~----~----~------~----~------~--~---