Re: passing variable values in javascript being served statically

2010-05-29 Thread gvkalra
Hi.
here is the code: http://pastebin.com/HtNq52aV

what i am trying to do::
get the visitor location from his IP address in {{latitude}} and
{{longitude}} . get my business location in
{{BUSINESS_LOCATION}} . then trace a route from visitor location
to my business location.


On May 25, 1:25 am, Daniel Roseman  wrote:
> On May 24, 8:24 pm,gvkalra wrote:
>
>
>
> > Hi.
> > I am trying to do something like this:
>
> > views.py
>
> > return render_to_response('abc.html',{'variable':value})
>
> > abc.html
>
> > 
> > dummy = {{variable}};
> > 
> > 
>
> > My problem:
> > I am not able to use dummy inside xyz.js ... OR is there some
> > other way by which I can use {{variable}} inside xyz.js ??
>
> This is generally the right approach. What is the value of 'variable'
> though? If it's a string, you'll need to wrap it in quotes for the
> javascript to be valid. Also, the rule with Javascript is that
> variables defined outside of a function need to be defined with "var"
> to be global.
>
>   var dummy = "{{variable}}";
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: passing variable values in javascript being served statically

2010-05-24 Thread Daniel Roseman
On May 24, 8:24 pm, gvkalra  wrote:
> Hi.
> I am trying to do something like this:
>
> views.py
>
> return render_to_response('abc.html',{'variable':value})
>
> abc.html
>
> 
> dummy = {{variable}};
> 
> 
>
> My problem:
> I am not able to use dummy inside xyz.js ... OR is there some
> other way by which I can use {{variable}} inside xyz.js ??

This is generally the right approach. What is the value of 'variable'
though? If it's a string, you'll need to wrap it in quotes for the
javascript to be valid. Also, the rule with Javascript is that
variables defined outside of a function need to be defined with "var"
to be global.

  var dummy = "{{variable}}";
--
DR.

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



Re: passing variable values in javascript being served statically

2010-05-24 Thread gvkalra
yes it is a js problem .. But I was looking for a way in which I
can use Django Variables passed by a view function inside a statically
served js ... since it's static, the template engine won't parse
it .

On May 25, 12:38 am, Rodrigue Villetard 
wrote:
> Hello,
>
> I think you can use xyz.js as a template :
>  return render_to_response('xyz.js'
>
>
>
> > {'variable':value})
>
> Your problem is more a javscript problem of variable visibility as  src="xyz.js"> doesn't properly make an include.
>
> regards.
>
> 2010/5/24 gvkalra 
>
>
>
> > Hi.
> > I am trying to do something like this:
>
> > views.py
>
> > return render_to_response('abc.html',{'variable':value})
>
> > abc.html
>
> >