Permalink
Browse files

Split Form.serialize into Form.serialize and Form.serializeElements. …

…The latter can be used stand-alone to serialize an array of elements you pass in, instead of the entire form [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5077 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent e2d8451 commit 2c6747f858481efa1bc3612e955861c13dc1c95b @dhh dhh committed Sep 8, 2006
@@ -1594,7 +1594,10 @@ var Form = {
Form.Methods = {
serialize: function(form) {
- var elements = Form.getElements($(form));
+ this.serializeElements(Form.getElements($(form)));
+ },
+
+ serializeElements: function(elements) {
var queryComponents = new Array();
for (var i = 0; i < elements.length; i++) {
@@ -1603,7 +1606,7 @@ Form.Methods = {
queryComponents.push(queryComponent);
}
- return queryComponents.join('&');
+ return queryComponents.join('&');
},
getElements: function(form) {
@@ -1615,6 +1618,7 @@ Form.Methods = {
for (var j = 0; j < tagElements.length; j++)
elements.push(tagElements[j]);
}
+
return elements;
},
@@ -1594,7 +1594,10 @@ var Form = {
Form.Methods = {
serialize: function(form) {
- var elements = Form.getElements($(form));
+ this.serializeElements(Form.getElements($(form)));
+ },
+
+ serializeElements: function(elements) {
var queryComponents = new Array();
for (var i = 0; i < elements.length; i++) {
@@ -1603,7 +1606,7 @@ Form.Methods = {
queryComponents.push(queryComponent);
}
- return queryComponents.join('&');
+ return queryComponents.join('&');
},
getElements: function(form) {
@@ -1615,6 +1618,7 @@ Form.Methods = {
for (var j = 0; j < tagElements.length; j++)
elements.push(tagElements[j]);
}
+
return elements;
},

0 comments on commit 2c6747f

Please sign in to comment.