From 3dc8f66f1378f8c932e684067a49be1ceb4d13d0 Mon Sep 17 00:00:00 2001 From: Eliazer Braun Date: Tue, 5 Mar 2013 11:03:45 -0500 Subject: [PATCH] Update serializeForm.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow callback to process the values..  form.serializeForm(function (val) {             return encodeURIComponent(val);         })); --- src/serializeForm.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/serializeForm.js b/src/serializeForm.js index 15eeecf..db351ce 100644 --- a/src/serializeForm.js +++ b/src/serializeForm.js @@ -6,7 +6,7 @@ * Licensed under the MIT, GPL licenses. */ (function( $ ){ - $.fn.serializeForm = function() { + $.fn.serializeForm = function(fn) { // don't do anything if we didn't get any elements if ( this.length < 1) { @@ -22,6 +22,7 @@ var named = this.name.replace(/\[([^\]]+)?\]/g, ',$1').split(','); var cap = named.length - 1; var $el = $( this ); + var val; // Ensure that only elements with valid `name` properties will be serialized if ( named[ 0 ] ) { @@ -33,7 +34,11 @@ // at the end, push or assign the value if ( lookup.length !== undefined ) { - lookup.push( $el.val() ); + val = $el.val(); + if($.isFunction(fn)){ + val = fn(val); + } + lookup.push( val ); }else { lookup[ named[ cap ] ] = $el.val(); }