From 412e3e27f27dda1ec8a4dffb4117b526ca6cc9df Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 30 Nov 2008 18:16:27 -0500 Subject: new upstream version of jquery form darcs-hash:20081130231627-5ed1f-7ee35664bf6cf3a35157bd861016a1210dfca79c.gz --- js/jquery.form.js | 73 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 21 deletions(-) (limited to 'js') diff --git a/js/jquery.form.js b/js/jquery.form.js index d9266bd64..cb8b5a660 100644 --- a/js/jquery.form.js +++ b/js/jquery.form.js @@ -1,6 +1,6 @@ /* * jQuery Form Plugin - * version: 2.12 (06/07/2008) + * version: 2.17 (06-NOV-2008) * @requires jQuery v1.2.2 or later * * Examples and documentation at: http://malsup.com/jquery/form/ @@ -10,7 +10,7 @@ * * Revision: $Id$ */ -(function($) { +;(function($) { /* Usage Note: @@ -67,13 +67,25 @@ $.fn.ajaxSubmit = function(options) { if (veto.veto) { log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); return this; - } + } + // provide opportunity to alter form data before it is serialized + if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSerialize callback'); + return this; + } + var a = this.formToArray(options.semantic); if (options.data) { options.extraData = options.data; - for (var n in options.data) - a.push( { name: n, value: options.data[n] } ); + for (var n in options.data) { + if(options.data[n] instanceof Array) { + for (var k in options.data[n]) + a.push( { name: n, value: options.data[n][k] } ) + } + else + a.push( { name: n, value: options.data[n] } ); + } } // give pre-submit callback an opportunity to abort the submit @@ -114,7 +126,7 @@ $.fn.ajaxSubmit = function(options) { options.success = function(data, status) { for (var i=0, max=callbacks.length; i < max; i++) - callbacks[i](data, status, $form); + callbacks[i].apply(options, [data, status, $form]); }; // are there files to upload? @@ -151,6 +163,7 @@ $.fn.ajaxSubmit = function(options) { } var opts = $.extend({}, $.ajaxSettings, options); + var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts); var id = 'jqFormIO' + (new Date().getTime()); var $io = $('