Re: [web2py] Re: javascript from ajax with :eval question

2019-05-21 Thread Eliezer (Vlad) Tseytkin
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 from echo
> 
> $("#your_button").on("click", function(){
> url_ajax = "{{=URL("your_controler", "echo")}}"
> ajax(url_ajax, [], ":eval"))
> })
> 
>
>
>
>
> Em ter, 21 de mai de 2019 às 19:43, Eliezer (Vlad) Tseytkin <
> westgate6...@gmail.com> escreveu:
>
>> 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 JavaScript string to be executed (the one that in my
>> example represented by result+=...); the reason I can't use a regular JS
>> ajax call which replaces html element is because I specifically need to
>> update multiple targets, so :eval is my only option). I can't use regular
>> {{...}} embeds either, because I can't reload the page - need to update
>> multiple html elements on the fly, in ajax mode.
>> That's why my only option seems to be constructing JavaScript which
>> executes the necessary updates on the page as a sequel to JavaScript
>> ajax(:eval) call. This is exactly how I ended up constructing JavaScript in
>> my controller function and the need to mix in some web2py objects in it.
>>
>> On Tue, May 21, 2019, 6:24 PM villas  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 dict(mydiv=mydiv)
>>>
>>> view  example.html
>>> {{=mydiv}}
>>>
>>> OR
>>> e.g. controller
>>> def example():
>>> cart = db(db.cart).select()
>>> mydiv = DIV(_id='Debug_Discount' )
>>> return dict(mydiv=mydiv, rows=rows)
>>>
>>> view  example.html
>>> {{=mydiv}}
>>> 
>>> 
>>> {{ =ASSIGNJS(cart) }}
>>> $('#Debug_Discount').html(cart);
>>> 
>>>
>>> Not sure whether any of the above will work or help,  but just
>>> experiment until you learn how best to mix it all together.
>>>
>>>
>>>
>>> On Tuesday, 21 May 2019 17:40:59 UTC+1, Vlad wrote:

 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 print it fully.

 Here is actual Javascript generated:

 $('#Debug_Discount').append('');
 var cart = [{"id": 125, "cart": 40, "product": 161, "quantity": 1,
 "price": 3000, "imported": null, "is_active": true, "created_on":
 "2019-05-17 15:47:52", "created_by": 1, "modified_on": "2019-05-17
 15:47:52", "modified_by": 1}];
 $('#Debug_Discount').append(''+cart+'');.

 Good ideas on final touch?

 On Tuesday, May 21, 2019 at 11:34:54 AM UTC-4, villas wrote:
>
> 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
>> the end], something like this:
>>
>> result = "$('#DebugID').append('"
>> result += "CONTENT"
>> result += "');"
>> return result
>>
>> Now, this works, and it displays CONTENT at the right place.
>>
>> But here is a catch: instead of "CONTENT" I want it to display an
>> object, for example Rows object which is returned by db.select.
>> In other words, whatever comes out when {{=rows}} is specified in
>> html view, I want to send via javascript.
>>
>> Obviously, the following 2 options are grossly incorrect and don't
>> work, for obvious reasons:
>>result += XML(rows)
>>result += "={{rows}}"
>>
>> So, how do I make the stuff display properly as passed over vial
>> javascript?
>>
>>
> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit
>>> 

Re: [web2py] Re: javascript from ajax with :eval question

2019-05-21 Thread Junior Phanter
# 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")}}"
ajax(url_ajax, [], ":eval"))
})





Em ter, 21 de mai de 2019 às 19:43, Eliezer (Vlad) Tseytkin <
westgate6...@gmail.com> escreveu:

> 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 JavaScript string to be executed (the one that in my
> example represented by result+=...); the reason I can't use a regular JS
> ajax call which replaces html element is because I specifically need to
> update multiple targets, so :eval is my only option). I can't use regular
> {{...}} embeds either, because I can't reload the page - need to update
> multiple html elements on the fly, in ajax mode.
> That's why my only option seems to be constructing JavaScript which
> executes the necessary updates on the page as a sequel to JavaScript
> ajax(:eval) call. This is exactly how I ended up constructing JavaScript in
> my controller function and the need to mix in some web2py objects in it.
>
> On Tue, May 21, 2019, 6:24 PM villas  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 dict(mydiv=mydiv)
>>
>> view  example.html
>> {{=mydiv}}
>>
>> OR
>> e.g. controller
>> def example():
>> cart = db(db.cart).select()
>> mydiv = DIV(_id='Debug_Discount' )
>> return dict(mydiv=mydiv, rows=rows)
>>
>> view  example.html
>> {{=mydiv}}
>> 
>> 
>> {{ =ASSIGNJS(cart) }}
>> $('#Debug_Discount').html(cart);
>> 
>>
>> Not sure whether any of the above will work or help,  but just experiment
>> until you learn how best to mix it all together.
>>
>>
>>
>> On Tuesday, 21 May 2019 17:40:59 UTC+1, Vlad wrote:
>>>
>>> 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 print it fully.
>>>
>>> Here is actual Javascript generated:
>>>
>>> $('#Debug_Discount').append('');
>>> var cart = [{"id": 125, "cart": 40, "product": 161, "quantity": 1,
>>> "price": 3000, "imported": null, "is_active": true, "created_on":
>>> "2019-05-17 15:47:52", "created_by": 1, "modified_on": "2019-05-17
>>> 15:47:52", "modified_by": 1}];
>>> $('#Debug_Discount').append(''+cart+'');.
>>>
>>> Good ideas on final touch?
>>>
>>> On Tuesday, May 21, 2019 at 11:34:54 AM UTC-4, villas wrote:

 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
> the end], something like this:
>
> result = "$('#DebugID').append('"
> result += "CONTENT"
> result += "');"
> return result
>
> Now, this works, and it displays CONTENT at the right place.
>
> But here is a catch: instead of "CONTENT" I want it to display an
> object, for example Rows object which is returned by db.select.
> In other words, whatever comes out when {{=rows}} is specified in html
> view, I want to send via javascript.
>
> Obviously, the following 2 options are grossly incorrect and don't
> work, for obvious reasons:
>result += XML(rows)
>result += "={{rows}}"
>
> So, how do I make the stuff display properly as passed over vial
> javascript?
>
>
 --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/oGAP28q6c_Q/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> 

Re: [web2py] Re: javascript from ajax with :eval question

2019-05-21 Thread Eliezer (Vlad) Tseytkin
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 JavaScript string to be executed (the one that in my
example represented by result+=...); the reason I can't use a regular JS
ajax call which replaces html element is because I specifically need to
update multiple targets, so :eval is my only option). I can't use regular
{{...}} embeds either, because I can't reload the page - need to update
multiple html elements on the fly, in ajax mode.
That's why my only option seems to be constructing JavaScript which
executes the necessary updates on the page as a sequel to JavaScript
ajax(:eval) call. This is exactly how I ended up constructing JavaScript in
my controller function and the need to mix in some web2py objects in it.

On Tue, May 21, 2019, 6:24 PM villas  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 dict(mydiv=mydiv)
>
> view  example.html
> {{=mydiv}}
>
> OR
> e.g. controller
> def example():
> cart = db(db.cart).select()
> mydiv = DIV(_id='Debug_Discount' )
> return dict(mydiv=mydiv, rows=rows)
>
> view  example.html
> {{=mydiv}}
> 
> 
> {{ =ASSIGNJS(cart) }}
> $('#Debug_Discount').html(cart);
> 
>
> Not sure whether any of the above will work or help,  but just experiment
> until you learn how best to mix it all together.
>
>
>
> On Tuesday, 21 May 2019 17:40:59 UTC+1, Vlad wrote:
>>
>> 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 print it fully.
>>
>> Here is actual Javascript generated:
>>
>> $('#Debug_Discount').append('');
>> var cart = [{"id": 125, "cart": 40, "product": 161, "quantity": 1,
>> "price": 3000, "imported": null, "is_active": true, "created_on":
>> "2019-05-17 15:47:52", "created_by": 1, "modified_on": "2019-05-17
>> 15:47:52", "modified_by": 1}];
>> $('#Debug_Discount').append(''+cart+'');.
>>
>> Good ideas on final touch?
>>
>> On Tuesday, May 21, 2019 at 11:34:54 AM UTC-4, villas wrote:
>>>
>>> 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
 the end], something like this:

 result = "$('#DebugID').append('"
 result += "CONTENT"
 result += "');"
 return result

 Now, this works, and it displays CONTENT at the right place.

 But here is a catch: instead of "CONTENT" I want it to display an
 object, for example Rows object which is returned by db.select.
 In other words, whatever comes out when {{=rows}} is specified in html
 view, I want to send via javascript.

 Obviously, the following 2 options are grossly incorrect and don't
 work, for obvious reasons:
result += XML(rows)
result += "={{rows}}"

 So, how do I make the stuff display properly as passed over vial
 javascript?


>>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/oGAP28q6c_Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/c5abcf26-bfd9-4461-baea-2f62ea695d61%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails 

Re: [web2py] Re: javascript from ajax with :eval question

2019-05-21 Thread Eliezer (Vlad) Tseytkin
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:

> 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 content is concerned)
>> seems right - I think I am missing the final touch, some javascript trick
>> that would print it fully.
>>
>> Here is actual Javascript generated:
>>
>> $('#Debug_Discount').append('');
>> var cart = [{"id": 125, "cart": 40, "product": 161, "quantity": 1,
>> "price": 3000, "imported": null, "is_active": true, "created_on":
>> "2019-05-17 15:47:52", "created_by": 1, "modified_on": "2019-05-17
>> 15:47:52", "modified_by": 1}];
>> $('#Debug_Discount').append(''+cart+'');.
>>
>> Good ideas on final touch?
>>
>> On Tuesday, May 21, 2019 at 11:34:54 AM UTC-4, villas wrote:
>>>
>>> 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
 the end], something like this:

 result = "$('#DebugID').append('"
 result += "CONTENT"
 result += "');"
 return result

 Now, this works, and it displays CONTENT at the right place.

 But here is a catch: instead of "CONTENT" I want it to display an
 object, for example Rows object which is returned by db.select.
 In other words, whatever comes out when {{=rows}} is specified in html
 view, I want to send via javascript.

 Obviously, the following 2 options are grossly incorrect and don't
 work, for obvious reasons:
result += XML(rows)
result += "={{rows}}"

 So, how do I make the stuff display properly as passed over vial
 javascript?


>>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/e69e8fd8-8a75-4d00-8c65-3b299ee6e80c%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/oGAP28q6c_Q/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/CAFoqysjxno08Yu6bUY9CK46tMP8ZBvDPUXrdOcYH0qPWDz%3DZvg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CABZ%2BKCBTPLm3n1jELAP9o9uheivpaBNJER_-KykjjochhcGzaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: javascript from ajax with :eval question

2019-05-21 Thread villas
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 dict(mydiv=mydiv)

view  example.html
{{=mydiv}}

OR
e.g. controller
def example():
cart = db(db.cart).select()
mydiv = DIV(_id='Debug_Discount' )
return dict(mydiv=mydiv, rows=rows)

view  example.html
{{=mydiv}}


{{ =ASSIGNJS(cart) }}
$('#Debug_Discount').html(cart);


Not sure whether any of the above will work or help,  but just experiment 
until you learn how best to mix it all together. 



On Tuesday, 21 May 2019 17:40:59 UTC+1, Vlad wrote:
>
> 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 print it fully.
>
> Here is actual Javascript generated:
>
> $('#Debug_Discount').append('');
> var cart = [{"id": 125, "cart": 40, "product": 161, "quantity": 1, 
> "price": 3000, "imported": null, "is_active": true, "created_on": 
> "2019-05-17 15:47:52", "created_by": 1, "modified_on": "2019-05-17 
> 15:47:52", "modified_by": 1}];
> $('#Debug_Discount').append(''+cart+'');. 
>
> Good ideas on final touch? 
>
> On Tuesday, May 21, 2019 at 11:34:54 AM UTC-4, villas wrote:
>>
>> 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 
>>> the end], something like this: 
>>>
>>> result = "$('#DebugID').append('"
>>> result += "CONTENT"
>>> result += "');"
>>> return result
>>>
>>> Now, this works, and it displays CONTENT at the right place. 
>>>
>>> But here is a catch: instead of "CONTENT" I want it to display an 
>>> object, for example Rows object which is returned by db.select. 
>>> In other words, whatever comes out when {{=rows}} is specified in html 
>>> view, I want to send via javascript. 
>>>
>>> Obviously, the following 2 options are grossly incorrect and don't work, 
>>> for obvious reasons:  
>>>result += XML(rows)
>>>result += "={{rows}}"
>>>
>>> So, how do I make the stuff display properly as passed over vial 
>>> javascript? 
>>>  
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c5abcf26-bfd9-4461-baea-2f62ea695d61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: javascript from ajax with :eval question

2019-05-21 Thread Junior Phanter
 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 content is concerned)
> seems right - I think I am missing the final touch, some javascript trick
> that would print it fully.
>
> Here is actual Javascript generated:
>
> $('#Debug_Discount').append('');
> var cart = [{"id": 125, "cart": 40, "product": 161, "quantity": 1,
> "price": 3000, "imported": null, "is_active": true, "created_on":
> "2019-05-17 15:47:52", "created_by": 1, "modified_on": "2019-05-17
> 15:47:52", "modified_by": 1}];
> $('#Debug_Discount').append(''+cart+'');.
>
> Good ideas on final touch?
>
> On Tuesday, May 21, 2019 at 11:34:54 AM UTC-4, villas wrote:
>>
>> 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
>>> the end], something like this:
>>>
>>> result = "$('#DebugID').append('"
>>> result += "CONTENT"
>>> result += "');"
>>> return result
>>>
>>> Now, this works, and it displays CONTENT at the right place.
>>>
>>> But here is a catch: instead of "CONTENT" I want it to display an
>>> object, for example Rows object which is returned by db.select.
>>> In other words, whatever comes out when {{=rows}} is specified in html
>>> view, I want to send via javascript.
>>>
>>> Obviously, the following 2 options are grossly incorrect and don't work,
>>> for obvious reasons:
>>>result += XML(rows)
>>>result += "={{rows}}"
>>>
>>> So, how do I make the stuff display properly as passed over vial
>>> javascript?
>>>
>>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/e69e8fd8-8a75-4d00-8c65-3b299ee6e80c%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAFoqysjxno08Yu6bUY9CK46tMP8ZBvDPUXrdOcYH0qPWDz%3DZvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: javascript from ajax with :eval question

2019-05-21 Thread Vlad
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 print it fully.

Here is actual Javascript generated:

$('#Debug_Discount').append('');
var cart = [{"id": 125, "cart": 40, "product": 161, "quantity": 1, "price": 
3000, "imported": null, "is_active": true, "created_on": "2019-05-17 
15:47:52", "created_by": 1, "modified_on": "2019-05-17 15:47:52", 
"modified_by": 1}];
$('#Debug_Discount').append(''+cart+'');. 

Good ideas on final touch? 

On Tuesday, May 21, 2019 at 11:34:54 AM UTC-4, villas wrote:
>
> 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 
>> the end], something like this: 
>>
>> result = "$('#DebugID').append('"
>> result += "CONTENT"
>> result += "');"
>> return result
>>
>> Now, this works, and it displays CONTENT at the right place. 
>>
>> But here is a catch: instead of "CONTENT" I want it to display an object, 
>> for example Rows object which is returned by db.select. 
>> In other words, whatever comes out when {{=rows}} is specified in html 
>> view, I want to send via javascript. 
>>
>> Obviously, the following 2 options are grossly incorrect and don't work, 
>> for obvious reasons:  
>>result += XML(rows)
>>result += "={{rows}}"
>>
>> So, how do I make the stuff display properly as passed over vial 
>> javascript? 
>>  
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/e69e8fd8-8a75-4d00-8c65-3b299ee6e80c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: javascript from ajax with :eval question

2019-05-21 Thread villas
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 the 
> end], something like this: 
>
> result = "$('#DebugID').append('"
> result += "CONTENT"
> result += "');"
> return result
>
> Now, this works, and it displays CONTENT at the right place. 
>
> But here is a catch: instead of "CONTENT" I want it to display an object, 
> for example Rows object which is returned by db.select. 
> In other words, whatever comes out when {{=rows}} is specified in html 
> view, I want to send via javascript. 
>
> Obviously, the following 2 options are grossly incorrect and don't work, 
> for obvious reasons:  
>result += XML(rows)
>result += "={{rows}}"
>
> So, how do I make the stuff display properly as passed over vial 
> javascript? 
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/311e1d62-0d13-41a8-8ebd-78f831a5aed8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.