How can I use {% for ROW in LIST %} within <script type="text/javascript"> tag?
How can I use {% for ROW in LIST %} within <script type="text/javascript"> tag? The code I refer to are lines 21 to 25.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | <head><!-- HEAD --> <title>Navi page</title> <meta charset="utf-8"> <meta name="description" content="Navi-ReactOS wordcloud"> {% load staticfiles %} <link rel="stylesheet" type="text/css" href="{% static 'navi_polls/style.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'navi_polls/jqcloud.css' %}" /> <!-- _______________________________________________________________________ --> <!-- jQuery --> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" src="{% static 'navi_polls/jqcloud-1.0.4.js' %}"></script> <!-- jQCloud 2 --> {% if untranslated_words %} <script type="text/javascript"> /*! * Create an array of word objects, each representing a word in the cloud */ var word_array = [ {% for row in unstranslated_words %} // Hoooooow to use Template tags in javascripts? {text: "{{ row.rosword }}", weight: -1}, {text: "{{ row.rosword }}", weight: -2, link: "http://jquery.com/"}, {text: "{{ row.rosword }}", weight: -3, html: {title: "I can haz any html attribute"}}, {% endfor %} {text: "Amet-15", weight: -5} // ...as many words as you want ]; $(function() { /*! * When DOM is ready, select the container element and call the * jQCloud method, passing the array of words as the first argument. */ $("#wordcloud2").jQCloud(word_array); }); </script> {% else %} <p>No untranslated words are available.</p> {% endif %} </head><!-- end HEAD --> |
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/da107ba8-2b38-4f1c-a2d6-8b12e17f30d7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home