You'll most likely need to use ajax() from web2py.js and use 'eval' and
return the javascript to run.
On Wednesday, November 6, 2013 11:39:16 AM UTC-7, step wrote:
>
> Can a single component update more than one target?
>
> I want to click on a link and have it update two targets at once, is this
> possible?
> The single-target cookbook is relatively simple:
>
> views/default/index.load:
> <span id="archive_op_fix"></span>
> {{=A(('fix
> it'),_href=URL(c='archive',f='op',args='fix'),cid='archive_op_fix')}}
> <div id="archive_op_fix_result"></div>
>
>
> views/default/index.html:
> {{extend 'layout.html'}}
> {{=LOAD(c='default',f='index.load',target='fix_it',ajax=True)}}
>
>
> controllers/archive.py:
> def op_archive(op):
> return False, 'Thumbs up'
> #return True, 'Thumbs down'
>
> def op():
> status = ''
> if request.args:
> status = SPAN('')
> op = request.args(-1)
> error, message = op_archive(op=op)
> if error:
> status['_class'] = 'icon icon-thumbs-down'
> else:
> status['_class'] = 'icon icon-thumbs-up'
> return dict(status=status)
>
> Now, by virtue of the *cid=* named argument in index.load, when I click
> the 'fix it' link a thumbs-up icon is inserted to the left of the link. Or
> a thumbs-down icon by changing op_archive in archive.py.
>
> But how can I *also* get the bottom div #archive_op_fix_result to display
> the second value (message) that op_archive() returns when I click the link?
> This would be updating two targets through a single component, something
> that the cid parameter can't do, can it? What alternative options do I have?
>
> TIA
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.