Jeremy Dunck wrote:
> On 1/19/07, rzimerman <[EMAIL PROTECTED]> wrote:
> >
> > I'd like to pass variable values from Django to client-side JavaScript
> > at page load time. Currently I've use Django's templating system to
> > dynamically rewrite the JavaScript code, such that the appropriate
> > values get set. But, is there a less hackish way? If it helps, I'm
> > already using MochKit.
>
> So far, I've been able to get away with making code static, and
> generating only data from the view.  I've been using
> django.util.simplejson to toss python object data into a js block,
> something like:
>
> <script type="text/javascript">
> var foo = {{ data }};
> alert(data['bouzouki']);
> </script>
>
> Do you think you'll need to dynamically generate logic as well?


No, just values. If need be, I can use boolean values for controlling
the programs flow.

I think you've answered my question -- It looks like dynamically
rewriting JavaScript (as oppose to serving the JS as a static file) is
the best way to pass variables at page load time.

Thank you!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to