Antonis, i think i understand the logic now. Thanks for the help.

Yingi Kem

> On 18 Jul 2017, at 3:25 PM, Antonis Christofides 
> <[email protected]> wrote:
> 
> Hi,
> 
> Define staticUrl in the base template, like this:
> 
> <script type="text/javascript">
>  staticUrl = "{% static '' %}";
> </script>
> <script type="text/javascript" src="{% static 'Game/d6.js' %}"></script>
> 
> Then, inside d6.js:
> 
> var imageBank = staticUrl + 'Game/blank.gif';
> 
> (It is also good practice to use a single JavaScript global variable, like
> app.staticUrl, in order to not pollute the global namespace, but that's 
> another
> issue.)
> 
> Regards,
> 
> Antonis
> 
> Antonis Christofides
> http://djangodeployment.com
> 
>> On 2017-07-18 16:53, yingi keme wrote:
>> I have a javascript file in my app static directory.
>> 
>> However inside my javascript file. I want to make use of an image. That is:
>> 
>> Javascript file is d6.js and it contains this code
>> 
>> var imageBank = baseUrl + "static/Game/blank.gif";
>> 
>> And then my html has this
>> 
>> {% load staticfiles %}
>> <script src="{% static 'Game/d6.js' %}"></script>
>> 
>> 
>> However when i render my html file the javascript file is unable to locate 
>> the img file (blank.gif). How do i get to reference an img file inside the 
>> static directory?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/ea3a37fe-9d28-ac5d-93a5-5d54d40011ba%40djangodeployment.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/DA0EAF5B-D15A-40DE-BCEE-02E2AEAF2F7F%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to