Re: Javascript with built-in templates tags

2009-08-11 Thread Michael
On Tue, Aug 11, 2009 at 2:53 PM, WilsonOfCanada wrote: > > I want to access the string from the list that is in the dictionary: > > function changeArea() > { >alert({{list_areas.British_Columbia}}); > } > > I get what I want in the generated HTML: > > function

Re: Javascript with built-in templates tags

2009-08-11 Thread WilsonOfCanada
I want to access the string from the list that is in the dictionary: function changeArea() { alert({{list_areas.British_Columbia}}); } I get what I want in the generated HTML: function changeArea() { alert(['Metro Vancouver', 'Metro Vancouver A', 'Sunshine Coast']); }

Re: Javascript with built-in templates tags

2009-08-09 Thread esatterwh...@wi.rr.com
On Aug 7, 9:31 pm, WilsonOfCanada wrote: > Hellos, > > I was wondering how to use {{ }} variables in javascript functions. > > ex. onchange = "changeArea({{ mooman |safe|escapejs}});" > > Thanks I had this problem too, it was pretty frustrating. I can to 2 different solutions.

Re: Javascript with built-in templates tags

2009-08-09 Thread Daniel Roseman
On Aug 9, 6:19 am, WilsonOfCanada wrote: > I tried that before, but it only seems to work when it is used on > the .html file. > > onchange="changeArea('{{ list_areas.BC|safe|escapejs}}') > > I need it to be onchange="changeArea('{{ list_areas|safe|escapejs}}') > so the function can

Re: Javascript with built-in templates tags

2009-08-08 Thread Sam Lai
Can you show us the generated template HTML, and if possible, the expected result? That way we can work out the issue with your django templates, rather than trying to guess your code. 2009/8/9 WilsonOfCanada : > > I tried that before, but it only seems to work when it is used on >

Re: Javascript with built-in templates tags

2009-08-08 Thread WilsonOfCanada
I tried that before, but it only seems to work when it is used on the .html file. onchange="changeArea('{{ list_areas.BC|safe|escapejs}}') I need it to be onchange="changeArea('{{ list_areas|safe|escapejs}}') so the function can use list_areas (My javascript and html are on separate files). On

Re: Javascript with built-in templates tags

2009-08-08 Thread Luke Seelenbinder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 That needs to be : alert({{ selectedAreas.BC }}); Look at the documentation. This problem is fairly obvious if you do: http://docs.djangoproject.com/en/dev/topics/templates/#variables I'm not trying to be mean, but please look at the docs before

Re: Javascript with built-in templates tags

2009-08-08 Thread WilsonOfCanada
I sent the variable as dictionary with lists {'BC:['Vancouver', 'Kamloops'], AB:['Calgary']} However, when I use the variable in the function, it is treated as a string. function changeArea(mooman) { alert(selectedAreas["BC"]); } This was not defined. Is there something more I need to

Re: Javascript with built-in templates tags

2009-08-08 Thread Daniel Roseman
On Aug 8, 7:49 pm, WilsonOfCanada wrote: > Thanks, > It worked, but out of curiosity, what do the additional quotes change > (why are they needed)? They're needed in Javascript, not in Django. If you looked at the generated source (via View Source in your browser) you could have

Re: Javascript with built-in templates tags

2009-08-08 Thread WilsonOfCanada
Thanks, It worked, but out of curiosity, what do the additional quotes change (why are they needed)? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Javascript with built-in templates tags

2009-08-08 Thread Matthias Kestenholz
On Sat, Aug 8, 2009 at 6:34 PM, WilsonOfCanada wrote: > > I am not sure; I am just trying to pass the variable from the > dictionary using render_to_response to a javascript function.  The > function is stored as a .js file.  This is a part of the code I am > using it for: > > {{

Re: Javascript with built-in templates tags

2009-08-08 Thread WilsonOfCanada
No, I placed the spaces in so it is more readable (I tested with spaces afterwards and they still do not work). The function is passed in by:

Re: Javascript with built-in templates tags

2009-08-08 Thread Luke Seelenbinder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I think your problem is just the spaces between the filters, try {{ mooman|safe|escapejs }}. Other then that, as long as the mooman is set in the context... that should work. Luke On Sat, Aug 8, 2009 at 12:34 PM, WilsonOfCanada wrote: -BEGIN

Re: Javascript with built-in templates tags

2009-08-08 Thread WilsonOfCanada
I am not sure; I am just trying to pass the variable from the dictionary using render_to_response to a javascript function. The function is stored as a .js file. This is a part of the code I am using it for: {{ selectCity|safe }} The {{ selectCity|safe }} works but the {{ mooman | safe |

Re: Javascript with built-in templates tags

2009-08-07 Thread Luke Seelenbinder
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wilson, Are you referring to rendering JS with template tags, or actual template tags in JS? In the first case, you use them like any other template tag. The second case is only possible if there is some JS library that uses Django-like templates.

Javascript with built-in templates tags

2009-08-07 Thread WilsonOfCanada
Hellos, I was wondering how to use {{ }} variables in javascript functions. ex. onchange = "changeArea({{ mooman |safe|escapejs}});" Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To