[Jifty-commit] r4953 - jifty/branches/jquery/share/web/static/js

Jifty commits jifty-commit at lists.jifty.org
Mon Jan 28 06:53:03 EST 2008


Author: gugod
Date: Mon Jan 28 06:52:58 2008
New Revision: 4953

Modified:
   jifty/branches/jquery/share/web/static/js/jifty.js

Log:
Fix  a bug where it alwasy getting the "checked" values of
radio and checkboxes elements, while it should be returning
null if they are not checked.


Modified: jifty/branches/jquery/share/web/static/js/jifty.js
==============================================================================
--- jifty/branches/jquery/share/web/static/js/jifty.js	(original)
+++ jifty/branches/jquery/share/web/static/js/jifty.js	Mon Jan 28 06:52:58 2008
@@ -167,7 +167,7 @@
             for (var i = 0; i < this.extras.length; i++)
                 possible.push(this.extras[i]);
 
-            for (var i = 0; i < possible.length; i++) {
+            for (var i = 0, l = possible.length; i < l; i++) {
                 if (Form.Element.getMoniker(possible[i]) == this.moniker)
                     elements.push(possible[i]);
             }
@@ -251,6 +251,7 @@
                     continue
                 a['fields'][field][type] = this._mergeValues(a['fields'][field][type],
                                                              Form.Element.getValue(f));
+
             }
         }
 
@@ -576,7 +577,6 @@
     // The type of Jifty form element
     getType: function (element) {
         element = Jifty.$(element);
-
         if (/^J:A-/.test(element.name)) {
             return "registration";
         } else if (/^J:A:F-/.test(element.name)) {
@@ -589,8 +589,11 @@
     },
 
     getValue: function(element) {
-        element = Jifty.$(element);
-        return jQuery(element).val();
+        var $el = jQuery(Jifty.$(element));
+        if ( $el.is(":checkbox, :radio") ) {
+            return $el.is(":checked") ? $el.val() : null
+        }
+        return $el.val();
     },
 
     // Validates the action this form element is part of


More information about the Jifty-commit mailing list