On Thu, Oct 17, 2013 at 10:06 AM, Daniele Procida <[email protected]> wrote:
> On Wed, Oct 16, 2013, Jonathan Slenders <[email protected]> wrote:
>
>>Some people still have javascript in their templates and they use template
>>tags inside their javascript. :(
>
> I am not sure if you're saying this is a bad thing, but it is unavoidable, 
> isn't it? For example I use the Google Maps API, and I don't know of any 
> other way to generate the map items dynamically than to build some of the JS 
> for it using template tags. Is there a problem doing it like this, and is 
> there a better way?

I see at least 2 more robust ways:

* Loading map items in another JSON request or as an embedded JSON
string in a hidden <textarea> or something. Then your JS code can
simply JSON.parse() the data and no other code generation is required.

* Using data-attributes that can be parsed using completely static JS
code: <div id="map" data-width="600" data-height="200">. You could
imagine storing map items as DOM elements with data-attributes
attached.

Bruno

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAB4BXAjqtoweb0JG%3DpggtRtP_t5_p1nCZZoHDKBL%3DLxyzorYDg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to