On Dec 1, 5:42 am, David <ww...@yahoo.com> wrote: > Hello, > > In my template file I have > > {% for value in data %} > <tr > {% ifequal all_domain 1 %} > class="odd" id="{{value.publisher}}" ???? > "showDomain('{{value.publisher}}', '{{value.country}}');" > {% else %} > ................... > {% endifequal %} > > > > {% endfor %} > > "showDomain(...)" is a JavaScript function. I would like this function > to be called in each iteration of the for-loop when all_domain == 1. > Anybody knows how to call this function? There are no events (click, > drag, mouseover, etc) here. > > Thanks so much.
This is waving a massive red flag for me. The template loop is evaluated when it is output, so if you really want to call the javascript function on each iteration of the loop, what you're effectively doing would be calling it immediately the page reaches the browser. Why would you want to do that? It sounds like you're putting some of the responsibility for building some of the page into Javascript, which is a very bad idea (what about those people with JS turned off, or on mobile phones without JS support, or using screenreaders?) Much better would be to do whatever logic is required within the view or the template itself, and leave Javascript for adding extra functionality. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.