It works, but the javascript you are generating has syntax errors. For example, you are missing the commas after every element.
Either way, dumping variables directly from django templates to JavaScript is not very elegant, you could make a JSON object in the view beforehand json_tags = json.dumps(list_commands) and then ouputting them in the template var avaibleTags = {{ json_tags|safe }} On Fri, Mar 20, 2015 at 7:14 PM, Stephen J. Butler <stephen.but...@gmail.com > wrote: > They do work. But did you check the generated page? I bet you get an > error in your browser's JavaScript console about syntax. > > On Fri, Mar 20, 2015 at 4:59 PM, dk <demi...@gmail.com> wrote: > > I am trying to create an autocomplete tag with jquery UI > > http://jqueryui.com/autocomplete/ > > > > > > > > in my view I got a list of commands, in the meant time I am just > testing > > it, so I have a list with ["a", "aaa", "b", "bbb"] > > <script> > > $(function() { > > var avaibleTags = [ > > {% for i in list_commands %} > > {{ i }} > > {% endfor %} > > ]; > > $( "#tags" ).autocomplete({ > > source: avaibleTags > > }); > > }); > > </script> > > > > but it doesn't work, does the string replacement of the template tags > > works on the script part ? or I might be missing something? thanks =) > > > > -- > > 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+unsubscr...@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/09c05edc-dd45-4c66-bae1-e30cd3bbdbf6%40googlegroups.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 django-users+unsubscr...@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/CAD4ANxWJEfceeVuxmaX4hrWYFHg%2B09xWLk4NT%2BjbmiCvrTJvHA%40mail.gmail.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 django-users+unsubscr...@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/CALn3ei2OQsKNgGCFBHJss%3DSCPgDqQ5VVpASQqBCi2wN8hUrjpA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.