> Probably a typo, but missing the closing single quote (') after the }} for
> the URL.

It is a typo here. It is correct in actual code.

> If 'myvar' is a Python variable, you're going

'myvar' is a not a python variable.
I pass the id of html element as argument.
Javascript code sets the value of that html element.

>From your reply, I guess that it is OK to return a javascript function
from controller (the way I did), provided that I adhere to your hints.

Perhaps then, why my code is failing to evaluate js function in View?

Regards,
Vineet


On Nov 8, 6:05 pm, Anthony <[email protected]> wrote:
> On Tuesday, November 8, 2011 7:45:59 AM UTC-5, Vineet wrote:
>
> > In a View, there is -->   ajax('{{=URL("salhead_edit")}}, [],
> > ':eval');
>
> Probably a typo, but missing the closing single quote (') after the }} for
> the URL.
>
> > "salhead_edit" returns js function -->  'abc(myvar1)'
>
> Unless 'myvar1' is a variable already defined in javascript somewhere in
> your page, that won't work. If 'myvar' is a Python variable, you're going
> to have to insert its actual value (in quotes if it is a string) into the
> JS code. Remember, from web2py's perspective in the controller, the JS code
> you're building is simply a string -- it doesn't know it is code. Something
> like:
>
> myvar1 = 'whatever'
> js = 'abc("%s");' % myvar1
>
> will return:
>
> abc("whatever");
>
> Note, it's a good idea to add the ";" at the end of the line.
>
> Anthony

Reply via email to