Skip to content

Commit

Permalink
Split Form.serialize into Form.serialize and Form.serializeElements. …
Browse files Browse the repository at this point in the history
…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
dhh committed Sep 8, 2006
1 parent e2d8451 commit 2c6747f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions actionpack/lib/action_view/helpers/javascripts/prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -1603,7 +1606,7 @@ Form.Methods = {
queryComponents.push(queryComponent);
}

return queryComponents.join('&');
return queryComponents.join('&');
},

getElements: function(form) {
Expand All @@ -1615,6 +1618,7 @@ Form.Methods = {
for (var j = 0; j < tagElements.length; j++)
elements.push(tagElements[j]);
}

return elements;
},

Expand Down
8 changes: 6 additions & 2 deletions railties/html/javascripts/prototype.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -1603,7 +1606,7 @@ Form.Methods = {
queryComponents.push(queryComponent);
}

return queryComponents.join('&');
return queryComponents.join('&');
},

getElements: function(form) {
Expand All @@ -1615,6 +1618,7 @@ Form.Methods = {
for (var j = 0; j < tagElements.length; j++)
elements.push(tagElements[j]);
}

return elements;
},

Expand Down

0 comments on commit 2c6747f

Please sign in to comment.