I need to update multiple targets when a link is clicked.
This example builds a list of links.
When the link is clicked, the callback needs to populate two different 
parts of the .html file.

The actual application uses bokeh for plotting.
The table of links is created dynamically.
The user will click on a link,  the 'linkDetails1' and 'linkDetails2' will 
hold the script and div return from calls to bokeh.component()
The user will click on a link, and the script, div returned from bokeh's 
component() function will populate the 'linkDetails'.

Obviously this naive approach does not work.
How can I make a list of links that when clicked on will populate two 
separate places in the .html file?

################################
#views/default/test.html:

{{extend 'layout.html'}}
{{=linkDetails1}}
{{=linkDetails2}}
{{=links}}

################################
# controllers/default.py:
def test():
    """
    example action using the internationalization operator T and flash
    rendered by views/default/index.html or views/generic.html

    if you need a simple wiki simply replace the two lines below with:
    return auth.wiki()
    """
    d = dict()
    links = []
    for ii in range(5):
      link = A("click on link %d"%ii, callback=URL('linkHandler/%d'%ii), )
      links.append(["Item %d"%ii, link])
    table = TABLE()
    table.append([TR(*rows) for rows in links])
    d["links"] = table
    d["linkDetails1"] = "linkDetails1" 
    d["linkDetails2"] = "linkDetails2" 
    return d

def linkHandler():
    import os
    d = dict()
    # request.url will be linked/N
    ii = int(os.path.split(request.url)[1])

    # want to put some information into linkDetails, some into linkDiv
    # this does not work:
    d = dict()
    d["linkDetails1"] = "linkHandler %d"%ii 
    d["linkDetails2"] = "linkHandler %d"%ii 
    return d 

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

Reply via email to