Inserting a static img tag with jQuery

Rails 3.1.3

This should be a basic question but it does not work for me, so I need
some help.

I would like to insert an image with jQuery after loading the page is
done.

More specifically,

$('#combine').click(function () {

$(’#tempimage’).html(’’);
});

this way. It does not work. I understand that the problem is the PATH.
The image is saved in “app/assets/images”.

$('#combine').click(function () {

$(’#tempimage’).html(’<%= image_tag ("/images/arrow_close.png") %>’);
});

this does not work either.

How can I do it?

Thanks in advance.

soichi

This here is useful stuff to read:

http://guides.rubyonrails.org/asset_pipeline.html

If not configured differently, the images that you have stored under
app/assets/images/arrow_close.png end up with an url of “/assets/
arrow_close.png” - it’s always a good idea to try this out in the
browser first and to check the console to see how the pipeline
processes the resources - the output here is usually quite verbose.

hope this helps,
stefan

Thanks for your help!

It works fine now.

soichi

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