So I have a folder in my assets/javascripts folder that runs an image slideshow called galleryview. Inside this folder is a themes directory holding images for my “next” and “previous” buttons thus…
assets/javascripts/galleryview/themes/
now the javascript running this, links to these images via this….
//Determine path between current page and filmstrip images
//Scan script tags and look for path to GalleryView plugin
$('script').each(function(i){
var s = $(this);
if(s.attr('src') && s.attr('src').match(/jquery\.galleryview/)){
img_path = s.attr('src').split('jquery.galleryview')[0]+'themes/';
}
});
HOWEVER, I’m using this in a Rails app now, so I need to point this img_path line to
assets/images/
so what should my imag_path look like now?
img_path = ?
Here is the entire javascript file code on jsfiddle….copy and past this into an editor and
the area I’m interested in is around line 389.
Not sure this code will exactly work, but I think you can use the
image_pathhelper to get you close. Something like:Put this inside a
.js.erbfile and the ERB shown above should be parsed and output the string"/assets/images/", assigningimg_pathto the value"/assets/themes/"Of course, you could also just do:
…but the upside of using the helper, I guess, is in case that the “assets” path ever changes you won’t need to update a hard-coded string.