Thanks! This works perfectly.
On Mon, Apr 8, 2013 at 6:01 PM, Nikolas Stevenson-Molnar
wrote:
> Injecting data into a template can be tricky. I would recommend doing
> two things:
>
> 1) Serialize your data to JSON in your view first using Python's json
> module. Something like this:
images_
On Tue, Apr 9, 2013 at 2:45 AM, Tom Evans wrote:
> On Tue, Apr 9, 2013 at 1:24 AM, Larry Martell wrote:
>> I appreciate the suggestion, but using a hidden field sounds very
>> kludgy. Is there no other way?
>>
>
> Remember that JSON = JavaScript Object Notation - its a way of writing
> literal JS
On Tue, Apr 9, 2013 at 1:24 AM, Larry Martell wrote:
> I appreciate the suggestion, but using a hidden field sounds very
> kludgy. Is there no other way?
>
Remember that JSON = JavaScript Object Notation - its a way of writing
literal JS objects.
var data = {{ json_encoded_literal }};
You've
Injecting data into client code is bound the be kludgy any way you slice
it. The reason for passing it through a hidden element has to do with
correct escaping of characters. Consider the following:
$.parseJSON("{{ images_as_json }}");
and lets say this is rendered as:
$.parseJSON("{foo: "bar"}"
I appreciate the suggestion, but using a hidden field sounds very
kludgy. Is there no other way?
On Mon, Apr 8, 2013 at 6:01 PM, Nikolas Stevenson-Molnar
wrote:
> Injecting data into a template can be tricky. I would recommend doing
> two things:
>
> 1) Serialize your data to JSON in your view fi
Injecting data into a template can be tricky. I would recommend doing
two things:
1) Serialize your data to JSON in your view first using Python's json
module. Something like this:
>>> images_as_json = json.dumps(images)
2) Rather than trying to inject it directly into JavaScript, which can
cause
I am passing a list of dictionaries to my template. In the template
language I can do this and it works as expected:
{% for row in images %}
{% endfor %}
But I need to process this data in jQuery. If I pass images into a
function like this:
my_func({{ images
7 matches
Mail list logo