Saturday, August 31, 2013

swapImage {src: ‘image2.jpg’} doesn't respond in Rails 3.1

swapImage {src: 'image2.jpg'} doesn't respond in Rails 3.1

I'm in the midst of upgrading my Rails app from 2.3 to 3.2, but I'm stuck
on 3.1 at the moment.
I'm currently struggling with converting references to image filenames
into a syntax that works with the asset pipeline. The main place I need
with help with this issue is with my button rollover swapImage statements.
Here's an example:
<%= image_submit_tag "signin.jpg", {:class => "swapImage { src:
'#{image_path('signinHover.jpg')}' }" %>
This works in development. But when I deploy this code to production, the
rollover still doesn't work. I get no apparent rollover response at all.
Also, the single quote still appears escaped when I view source:
<input class="swapImage {src: &#x27;/assets/signinHover.jpg&#x27;}"
src="/assets/signin.jpg" type="image" />
I'm guessing this might be part of my problem.
I'm also wondering if perhaps I'm not loading my javascript/jquery assets
correctly using the asset pipeline. But when I check
https://staging.genlighten.com/assets/application.js, I see the swapImage
code appearing just fine.
I'd appreciate advice on how to implement swapImage correctly in Rails
3.1, with the proper syntax for images served by the asset pipeline.
Alternatively, is there a better approach to rollover button images that I
should use instead?
Thanks very much,
Dean Richardson Genlighten.com

No comments:

Post a Comment