{% for shbf in should_have_found_list %}
should_have_found_list = ShouldHaveFound.objects.filter(enabled=1)
return render_to_response(template_name, RequestContext(request, {'form': form,'fields': simplejson.dumps(form.field_mapping),}))
You can embed js anywhere in your template, e.g.:{% for shbf in should_have_found_list %}<script type="text/javascript">my_js_function(shbf);</script>{% endfor %}
--
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...@googlegroups.com.
To post to this group, send email to django...@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/CACwCsY4PvmRLOkpCrsRps4xLixqRbjkeMhqdvoOuS%2B3g9-RgEA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
On Tuesday, October 15, 2013 8:45:09 AM UTC-7, Larry....@gmail.com wrote:You can embed js anywhere in your template, e.g.:{% for shbf in should_have_found_list %}<script type="text/javascript">my_js_function(shbf);</script>{% endfor %}I think you meant to write:my_js_function({{shbf}});
I don't understand why you are JSON encoding form.field_mapping for the fields template variable.
But accessing should_have_found_list in template has no problems. I have separate JS file that contains functions (event handlers for buttons etc.). I can't figure out (total newbie in JS :D ) how to access (or pass) should_have_found_list there. (Sorry I wasn't clear enough in my first post)