introduce html_headers.on_load() method as a shortcut for add_post_inline_script('''jQuery(document).ready(...''')
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 12 Nov 2008 16:07:40 +0100
changeset 28 9b7067bfaa15
parent 27 ef1c80154d6f
child 29 7d14f1eadded
introduce html_headers.on_load() method as a shortcut for add_post_inline_script('''jQuery(document).ready(...''')
common/utils.py
--- a/common/utils.py	Tue Nov 11 16:17:50 2008 -0800
+++ b/common/utils.py	Wed Nov 12 16:07:40 2008 +0100
@@ -141,6 +141,12 @@
 
     def add_post_inline_script(self, content):
         self.post_inlined_scripts.append(content)
+
+    def add_onload(self, jscode):
+        self.add_post_inline_script(u"""jQuery(document).ready(function () {
+ %s
+ });""" % jscode)
+        
     
     def add_js(self, jsfile):
         """adds `jsfile` to the list of javascripts used in the webpage