diff --git a/js/jquery.form.js b/js/jquery.form.js index d9266bd643..cb8b5a6609 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 = $('