Sure. I think it would look something like this (in gluon/ clienttools.py):
class PageManager(object): def __init__(self, response): if not response.scripts: response.scripts = [] def addscript(self,script): response.scripts.append(script) Then in web2py_ajax.html as the last thing in the $(document).ready function: {{if response.scripts:}} {{for s in response.scripts:}} {{=s}} {{pass}} {{pass}} Then in your db.py model: from gluon.clienttools import PageManager pagemanager=PageManager(response) Then in your controller: def index(): pagemanager.addscript("$('test').hide();") response.flash=T('Welcome to web2py') return dict(message=T('Hello World')) Ideally, the clienttools module would be chocked full of jquery helpers too :) On Feb 11, 1:40 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > Can you write the addscript function? > > On Feb 11, 1:31 pm, "mr.freeze" <nfre...@gmail.com> wrote: > > > Good stuff. That reminds me...I think a good addition to web2py would > > be some kind of page/script manager (like t2's response.files on > > steroids). Just thinking off the top of my head here but... > > > response.stylesheets (list rendered in the head of we2py_ajax.html) > > response.pagescripts(list rendered in the head of we2py_ajax.html) > > response.scripts(list rendered after the end of $(document).ready) > > > pagemanager.includestylesheet(path_to_static_css) > > pagemanager.includescript(path_to_static_js) > > pagemanager.addscript(your_script_snippet) > > > Each pagemanager method would check to see if the file/snippet already > > exists in the corresponding response.[stylesheets,pagescripts,scripts] > > before adding to prevent duplicates. > > > Then some jQuery helpers to abstract common selectors,manipulators and > > effects so you could do: > > > pagemanager.addscript(jquery.getbyid('testid').fadein('slow')) > > pagemanager.addscript(jquery.getbyclass('testclass').setattribute > > ('src','/images/hat.gif')) > > > Can you tell I'm bent on programming everything in Python? > > > On Feb 11, 11:26 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > do not miss these: > > > >http://devsnippets.com/reviews/using-jquery-to-style-design-elements-... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---