reload component

31 views
Skip to first unread message

DenesL

unread,
Aug 25, 2011, 4:14:31 PM8/25/11
to web2py-developers

Any reason for not having a "reload component" function included in
web2py?.

It seems to me like it should be there, instead of having to define
something like

def reload(target):
def js(form):
response.js='web2py_component("%s","%s")' %(URL(target), target)
return js

whenever needed, and it is almost required when working with
components.

Denes

DenesL

unread,
Aug 26, 2011, 1:02:37 PM8/26/11
to web2py-developers
bump...

DenesL

unread,
Aug 28, 2011, 8:55:19 PM8/28/11
to web2py-developers
A more generic way could be:

def refresh(target):
response.headers['web2py-component-command'] = 'refresh_%s();'
%target
return XML("""
<SCRIPT TYPE="text/javascript">
<!--
function refresh_%s() {
web2py_component("%s","%s"); };
// -->
</SCRIPT>
""" %(target, URL(target), target))


In the controller you would do e.g.:
...
return CAT(form, refresh('a_target'))

It can be modified to refresh multiple targets.

pros/cons?
Reply all
Reply to author
Forward
0 new messages