[web2py] Re: Why is this ajax function not working fine?

2016-03-29 Thread Jacob Devin
Thank you Anthony. It worked flawlessly!

On Tuesday, March 29, 2016 at 6:50:24 PM UTC+5:30, Anthony wrote:
>
> On Tuesday, March 29, 2016 at 6:09:57 AM UTC-4, Jacob Devin wrote:
>>
>> view:
>>
>> {{extend 'layout.html'}}
>> {{for row in rows:}}
>> 
>> {{=row.name}}
>> 
>> 
>> check 
>> 'about'
>>
>
> Please review the documentation. The second argument to the ajax() 
> function is a list of "name" attributes of form input elements -- it cannot 
> simply be a list of raw data values you want to pass to the server (and you 
> certainly shouldn't expect the Python identifiers used in the template to 
> appear in request.vars -- the Javascript code never even sees those 
> identifiers). In this case, because you are not extracting values from form 
> input elements but simply want to pass existing data values, you should 
> instead add those values to the URL itself:
>
> ajax('{{=URL('default', 'about_group', args=row.id)}}', [], '{{=row.id}}')
>
> With the above, in the controller you can get the value of row.id via 
> request.args(0). Also, note the change of the "target" argument to the 
> row.id value -- this will ensure that each target element gets its own 
> unique ID (you cannot give the same CSS id to multiple elements on the 
> page). Of course, you will also need to do:
>
>  
>
>
> Anthony
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Why is this ajax function not working fine?

2016-03-29 Thread Anthony
On Tuesday, March 29, 2016 at 6:09:57 AM UTC-4, Jacob Devin wrote:
>
> view:
>
> {{extend 'layout.html'}}
> {{for row in rows:}}
> 
> {{=row.name}}
> 
> 
> check 
> 'about'
>

Please review the documentation. The second argument to the ajax() function 
is a list of "name" attributes of form input elements -- it cannot simply 
be a list of raw data values you want to pass to the server (and you 
certainly shouldn't expect the Python identifiers used in the template to 
appear in request.vars -- the Javascript code never even sees those 
identifiers). In this case, because you are not extracting values from form 
input elements but simply want to pass existing data values, you should 
instead add those values to the URL itself:

ajax('{{=URL('default', 'about_group', args=row.id)}}', [], '{{=row.id}}')

With the above, in the controller you can get the value of row.id via 
request.args(0). Also, note the change of the "target" argument to the 
row.id value -- this will ensure that each target element gets its own 
unique ID (you cannot give the same CSS id to multiple elements on the 
page).

Anthony

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Why is this ajax function not working fine?

2016-03-29 Thread Niphlod
a taddle bit of recap, seems that you're loosing the bigger picture 

ANYTHING (or, the 99%) of things in views contained in a {{=blabla}} are 
properly escaped.

Back to the "problem":
- first of all, you shouldn't generate  multiple times. 
Every element with an id attribute should be the only instance in the page
- second: you'd really check into what leonel suggested, it cuts the 
complexity
- third, for completeness sake and for that only: in cases like this I like 
to take a step back and iterate over small changes, to see where everything 
is falling apart...
a) let's start with check about
b) let's get "something" become  "ajax('url', ['parameter'], 'target');"
- check about
c) let's get "url" become a proper url
   - check about
d) let's get "parameter" become the row.id 
   - check about

voilà, no syntax errors.

On Tuesday, March 29, 2016 at 12:56:20 PM UTC+2, Jacob Devin wrote:
>
> now it says:
>  unexpected character after line 
> continuation character (default/index.html, line 83)
>
> earlier it was giving no response on clicking as i expected it to work as 
> per its onclick function.
>
> On Tuesday, March 29, 2016 at 4:10:02 PM UTC+5:30, Kiran Subbaraman wrote:
>>
>> Escaping the inner-quotes: > onclick="ajax('{{=URL(\'default\',\'about_group\')}}',[row.id
>> ],'target');">
>> Also will be a good idea to see what sort of errors appear on your 
>> browser's console, and if the generated page contains the callback url that 
>> you expect.
>>
>> 
>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>>
>> On Tue, 29-03-2016 3:59 PM, Jacob Devin wrote:
>>
>>
>> {{extend 'layout.html'}}
>> {{for row in rows:}}
>> 
>> {{=row.name}}
>> 
>> 
>> > onclick="ajax('{{=URL('default','about_group')}}',[row.id],'target');">check 
>> 'about'
>> 
>>  
>> {{pass}}
>>
>>
>>
>> def index():
>> rows=db(db.groups.id>0).select()
>> return locals()
>> def about_group():
>> row=db(db.groups.id 
>> 
>> ==request.vars.row.id).select().first()
>> return row.about
>> It ain't working with div onclick too. What's the problem now?
>>
>> On Tuesday, March 29, 2016 at 3:48:50 PM UTC+5:30, Leonel Câmara wrote: 
>>>
>>> It shouldn't be on href it should be on onclick. 
>>>
>>> Consider using a trapped link for that instead.
>>>
>>> http://web2py.com/books/default/chapter/29/12/components-and-plugins#Trapped-Ajax-links-and-the-A-Helper
>>>
>> -- 
>> 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+un...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Why is this ajax function not working fine?

2016-03-29 Thread Jacob Devin
now it says:
 unexpected character after line 
continuation character (default/index.html, line 83)

earlier it was giving no response on clicking as i expected it to work as 
per its onclick function.

On Tuesday, March 29, 2016 at 4:10:02 PM UTC+5:30, Kiran Subbaraman wrote:
>
> Escaping the inner-quotes:  onclick="ajax('{{=URL(\'default\',\'about_group\')}}',[row.id
> ],'target');">
> Also will be a good idea to see what sort of errors appear on your 
> browser's console, and if the generated page contains the callback url that 
> you expect.
>
> 
> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>
> On Tue, 29-03-2016 3:59 PM, Jacob Devin wrote:
>
>
> {{extend 'layout.html'}}
> {{for row in rows:}}
> 
> {{=row.name}}
> 
> 
>  onclick="ajax('{{=URL('default','about_group')}}',[row.id],'target');">check 
> 'about'
> 
>  
> {{pass}}
>
>
>
> def index():
> rows=db(db.groups.id>0).select()
> return locals()
> def about_group():
> row=db(db.groups.id 
> 
> ==request.vars.row.id).select().first()
> return row.about
> It ain't working with div onclick too. What's the problem now?
>
> On Tuesday, March 29, 2016 at 3:48:50 PM UTC+5:30, Leonel Câmara wrote: 
>>
>> It shouldn't be on href it should be on onclick. 
>>
>> Consider using a trapped link for that instead.
>>
>> http://web2py.com/books/default/chapter/29/12/components-and-plugins#Trapped-Ajax-links-and-the-A-Helper
>>
> -- 
> 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+un...@googlegroups.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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Why is this ajax function not working fine?

2016-03-29 Thread Kiran Subbaraman
Escaping the inner-quotes: onclick="ajax('{{=URL(\'default\',\'about_group\')}}',[row.id 
],'target');">
Also will be a good idea to see what sort of errors appear on your 
browser's console, and if the generated page contains the callback url 
that you expect.



Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On Tue, 29-03-2016 3:59 PM, Jacob Devin wrote:


{{extend 'layout.html'}}
{{for row in rows:}}

{{=row.name }}


http://row.id/>],'target');">check 'about'


 
{{pass}}



def index():
rows=db(db.groups.id >0).select()
return locals()
def about_group():
row=db(db.groups.id 
==request.vars.row.id 
).select().first()

return row.about
It ain't working with div onclick too. What's the problem now?

On Tuesday, March 29, 2016 at 3:48:50 PM UTC+5:30, Leonel Câmara wrote:

It shouldn't be on href it should be on onclick.

Consider using a trapped link for that instead.

http://web2py.com/books/default/chapter/29/12/components-and-plugins#Trapped-Ajax-links-and-the-A-Helper



--
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 
.

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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Why is this ajax function not working fine?

2016-03-29 Thread Jacob Devin

{{extend 'layout.html'}}
{{for row in rows:}}

{{=row.name}}


check 
'about'

 
{{pass}}



def index():
rows=db(db.groups.id>0).select()
return locals()
def about_group():
row=db(db.groups.id 

==request.vars.row.id).select().first()
return row.about
It ain't working with div onclick too. What's the problem now?

On Tuesday, March 29, 2016 at 3:48:50 PM UTC+5:30, Leonel Câmara wrote:
>
> It shouldn't be on href it should be on onclick.
>
> Consider using a trapped link for that instead.
>
> http://web2py.com/books/default/chapter/29/12/components-and-plugins#Trapped-Ajax-links-and-the-A-Helper
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Why is this ajax function not working fine?

2016-03-29 Thread Leonel Câmara
It shouldn't be on href it should be on onclick.

Consider using a trapped link for that instead.
http://web2py.com/books/default/chapter/29/12/components-and-plugins#Trapped-Ajax-links-and-the-A-Helper

-- 
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.
For more options, visit https://groups.google.com/d/optout.