>
> (1) After searching on the web I have see that the following are two
> valid ways to link to an image in the static/images folder. However,
> the first way is not working for me. Could this be because I deleted
> all css files and js files (except jquery) that come with the Welcome
> app? Please let me know if I should post more information.
>
> background-image: url("{{=URL('static',
> 'images/roughcloth.png')}}");
>
If this is a CSS file in your static folder, then it is not a web2py
template, and you cannot use web2py template code in it. You could serve a
CSS file dynamically based on a web2py template, but that's somewhat
inefficient, so you're probably better off hard coding the URL.
> (2) I use jquery to add some html images to the html file. The working
> code is:
>
> $("section").each(function(index){
> idtag = 's' + (index + 1)
> $(this).attr('id', idtag);
> $(this).append("<div class='nav'>\
> <img
> class='prev' src='/microeconslides/static/images/left_arrow.png'/>\
> <img
> class='next'
> src='/microeconslides/static/images/right_arrow.png'/>\
> </div>");
> $(this).css('display', 'none' );
> });
>
> Is there a way to use {{=URL(...)}} to add links to the images instead
> of the way I have done. I am not sure how to deal with the inverted
> commas if the URL method is used.
>
$(this).append("<div class='nav'>\
<img class='prev' src='{{=URL('static', 'images/left_arrow.png')}}' />\
<img class='next' src='{{=URL('static', 'images/right_arrow.png')}}'
/>\
</div>");
First, let's refer to the "inverted commas" as "single quotes". :-)
Note, the single quotes inside the {{...}} aren't a problem because the
content inside the braces is Python and evaluated independently of the
content outside the braces.
Anthony