[Answer]-Output a value in jQuery from Django

0👍

Django is escaping the JSON string try {{ content|safe }}

To expand a bit, Django offers all sorts of filters (of which ‘safe’ is one) that you can apply to variables you are outputting to templates.

Another example would be {{ content|lower }} to output lower case text.

The docs for this are here

1👍

i think your variable temp has value, what you need.

if content equals “{a:1, b:2}“, html under rendering will be var temp = {a:1, b:2};

and then you can write

$(document).on('pagebeforeshow', '#index', function (event) {
    var siteData = temp;     // window.temp
});

0👍

Please post exact errors with full traceback, as they appear in Javascript console, without them is just a shot in the dark..

I believe you have incorrect syntax

var temp is global it will be accessible in builder.js, but siteData is invalid syntax for object literal; should be something like:

var siteData = { key: value}

Leave a comment