I’m trying to access images uploaded to my Rails app with jQuery, i.e., switching images out and the like. The jQuery’s pretty straightforward:
$('#a1').change(function() {
var src = $(this).val();
$('#t1').html(src ? "<img src='../../images/000/000/"+src+".jpg' />":"");
});
I’m totally stuck when trying to use the Rails asset call with jQuery. I can call up the required images elsewhere on the page, thus:
@a.image.url(:thumb)
Any help would be great.
I’m going to answer this myself in case it helps someone. Instead of accessing the images directly with jQuery I assigned IDs to them in Rails, thus:
And subsequently handled their visibility in jQuery:
Might help someone.