There's a forloop.last variable that you could test.  Eg:
var crimes =  [
 {% for crime in crime_list %}
 [ {{crime.longitude}},
{{ crime.latitude }},'{{ crime.address }}','{{ crime.type }}','{{ crime.date 
}}']
{% if not forloop.last %},{% endif %}
 {% endfor %}
];

On Jul 19, 12:35 pm, cjl <[EMAIL PROTECTED]> wrote:
> DU:
>
> I am a newbie, and I'm working on a simple tutorial for other
> newbies.  I am trying to generate some javascript, and I have the
> following code in my template:
>
> var crimes =  [
>  {% for crime in crime_list %}
>  [ {{crime.longitude}},
> {{ crime.latitude }},'{{ crime.address }}','{{ crime.type }}','{{ crime.date 
> }}'],
>  {% endfor %}
> ];
>
> When this template is rendered to a webpage, I can get something like
> the following:
>
> var crimes = [
>         [-78.817828,42.904851,'17 Rapin
> Place','homicide','2006-01-05'],
>         [-78.889458,42.897707,'155 Pennsylvania
> Street','homicide','2006-04-17'],
>         [-78.884766,42.915257,'446 West
> Ferry','homicide','2006-01-10'],
> ];
>
> This is fine, but I think the trailing comma in the final array item
> is causing a javascript error in IE. Is there a way to rewrite my
> template code to avoid the trailing comma?
>
> Thanks in advance,
> cjl


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to