Commits

Anonymous committed 6952b0b

[svn] fix observe_form, which I think has always been broken, even in rails
minor cleanup

Comments (0)

Files changed (2)

tests/test_prototype.py

             observe_field("glass", frequency=300,url='http://www.example.com/reorder_if_empty'))
 
     def test_observe_form(self):
-        self.assertEqual("""<script type="text/javascript">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true})})\n//]]>\n</script>""",
+        self.assertEqual("""<script type="text/javascript">\n//<![CDATA[\nnew Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true, parameters:Form.serialize('cart')})})\n//]]>\n</script>""",
             observe_form("cart", frequency=2,url='http://www.example.com/cart_changed'))
 
     def test_update_element_function(self):
 if __name__ == '__main__':
     suite = [unittest.makeSuite(TestPrototypeHelper)]
     for testsuite in suite:
-        unittest.TextTestRunner(verbosity=1).run(testsuite)
+        unittest.TextTestRunner(verbosity=1).run(testsuite)

webhelpers/rails/prototype.py

     `link_to_remote <#link_to_remote>`_.
     """
     if options.get('frequency') > 0:
-        return build_observer('Form.Element.Observer', field_id, **options)
+        class_ = 'Form.Element.Observer'
     else:
-        return build_observer('Form.Element.EventObserver', field_id, **options)
+        class_ = 'Form.Element.EventObserver'
+    return build_observer(class_, field_id, **options)
 
 def observe_form(form_id, **options):
     """
     of the form.
     """
     if options.get('frequency'):
-        return build_observer('Form.Observer', form_id, **options)
+        class_ = 'Form.Observer'
     else:
-        return build_observer('Form.EventObserver', form_id, **options)
+        class_ = 'Form.EventObserver'
+    return build_observer(class_, form_id, submit=form_id, **options)
 
 def options_for_ajax(options):
     js_options = build_callbacks(options)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.