Commits

Anonymous committed 6952b0b

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

  • Participants
  • Parent commits 00d5f52

Comments (0)

Files changed (2)

File 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)

File 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)