Integration of Mike Alsup's excellent form serialization code. The benefits are as follows:

- New method: .serializeArray()
This returns an array of name/value pairs representing the contents of a form, or individual input elements.
- Enhancement: .serialize()
The results are correct now (as opposed to the mess from before), and allows you to serializes forms directly (rather than just the input elements).
- Enhancement: .val()
This now returns the correct value when dealing wih selects. Additionally, when dealing with multiple selects, it returns an array of values.

Based upon Mike's code:
http://malsup.com/jquery/form/comp/form.js

and test suite:
http://malsup.com/jquery/form/comp/test.html
This commit is contained in:
John Resig 2007-09-05 17:06:05 +00:00
parent f28f199dc0
commit f96bf10415
7 changed files with 129 additions and 37 deletions

View file

@ -42,7 +42,7 @@ test("bind()", function() {
function selectOnChange(event) {
equals( event.data, counter++, "Event.data is not a global event object" );
};
$("select").each(function(i){
$("#form select").each(function(i){
$(this).bind('change', i, selectOnChange);
}).trigger('change');