Aaahhh got it
Thank you very much!!
On Tue, May 21, 2019, 7:14 PM Junior Phanter wrote:
> # controller return javascript(Jquery) to eval
> def echo:
> import json
> return "$('#target').html(%s)" %(json.dumps(DIV("Hello",
> STRONG("world"), "Escape this?").xml()))
>
> #view
>
> get
# controller return javascript(Jquery) to eval
def echo:
import json
return "$('#target').html(%s)" %(json.dumps(DIV("Hello",
STRONG("world"), "Escape this?").xml()))
#view
get from echo
$("#your_button").on("click", function(){
url_ajax = "{{=URL("your_controler", "echo")}}"
I am very familiar with controllers/views/helpers the way you just
specified, but it doesn't help me because here is my context:
I am using ajax function from JavaScript, as a response to a certain event
on the page. This ajax is called with :eval option which allows me to
construct actual
Could you please clarify:
You mentioned {{=json.dumps()}} which looks like code executed in Python.
But in "result+=" I am constructing an expression which is actually
executed in JavaScript. Did you mistype or I'm missing something?
On Tue, May 21, 2019, 5:59 PM Junior Phanter wrote:
>
Not sure what you are trying to do, work in the controller or view, or why
you are trying to append with JS.
Maybe you could learn to use the web2py helpers...
e.g. controller
def example():
cart = db(db.cart).select().as_list()
mydiv = DIV(cart, _id='Debug_Discount' )
return
resultado + = {{=json.dumps(DIV().xml())}}
Em ter, 21 de mai de 2019 às 13:41, Vlad escreveu:
> ALMOST :)
>
> result += ASSIGNJS(cart=cart)
> result += "$('#Debug_Discount').append(''+cart+'');"
>
> this comes out as [object Object]
>
> But generated Javascript (as far as the object's
ALMOST :)
result += ASSIGNJS(cart=cart)
result += "$('#Debug_Discount').append(''+cart+'');"
this comes out as [object Object]
But generated Javascript (as far as the object's content is concerned)
seems right - I think I am missing the final touch, some javascript trick
that would
Maybe this: ASSIGNJS
http://www.web2py.com/books/default/chapter/29/05/the-views#ASSIGNJS
On Tuesday, 21 May 2019 15:43:25 UTC+1, Vlad wrote:
>
> I am calling ajax function with :eval and setting up some javascript [from
> the controller] to be executed [as per :eval option js is executed in
8 matches
Mail list logo