• loading...

A helper is used to build links.

A helper is used to build links where you can use use ajax callback

# Build links

>>> print A('<click>', XML('<b>me</b>'),
a href='http://www.web2py.com'>&lt;click&gt;<b>me/b></a>

Ajax features require jQuery and "static/js/web2py_ajax.js", which are automatically included by placing
{{include 'web2py_ajax.html'}} in the layout head. "views/web2py_ajax.html" defines some variables based
on request and includes all necessary js and css files.

Attributes / Arguments

Instead of _href you can pass the URL using the callback argument where the effect of pressing the link will be an ajax call to "myaction" instead of a redirection.

{{=A('click me', callback=URL('myaction'))}}

Instead of redirection, optionally using target argument the response of the ajax callback will be stored in the DIV with id equal to "t".

{{=A('click me', callback=URL('myaction'), target="t")}}

<div id="t"><div>

Upon response, the closest tag matching "div#b" will be deleted. In below case, the button will be deleted

<div id="b">{{=A('click me', callback=URL('myaction'), delete='div#b")}}</div>

# Typical application is:
# Pressing the button will perform the callback and delete the table row.
{{=A('click me', callback=URL('myaction'), delete='tr")}}

Special argument. By clicking on the link with cid argument causes the content to be loaded in the div. This is similar but more powerful than the previous syntax since it is designed to refresh page components. 

{{=A('linked page', _href='http://example.com', cid='myid')}}
<div id="myid"></div>





Powered by

Hosted on
(affiliated link)