+
+ this.vars = a;
+
+ return this;
+}
+
+/**
+ * Final form submission plugin usually used in conjunction with
+ * form() and getForm(). If a second argument is a valid function
+ * then it will be called before the form vars are sent to the
+ * backend. If this pre-submit function returns exactly "false"
+ * then it will abort further processing otherwise the process
+ * will continue according to the first and third arguments.
+ *
+ * If the first argument is a function, and it exists, then the form
+ * values will be submitted and that callback function called. If
+ * the first argument is a string value then the "load()" plugin
+ * will be called which will populate the innerHTML of the indicated
+ * element and a callback will be called if there is third argument.
+ * If there are no arguments then the form values are submitted with
+ * an additional variable (evaljs=1) which indicates to the backend
+ * to to prepare the returned results for evaluation, ie; the result
+ * needs to be valid javascript all on a single line.
+ *
+ * Usage example:
+ *
+ * $.fn.myvars = function() {
+ * this.vars = [];
+ * for (var i in this) {
+ * if (this[i] instanceof Function || this[i] == null) continue;
+ * this.vars.push({name: i, value: this[i].length});
+ * }
+ * return this;
+ * }
+ *
+ * precb = function(vars) {
+ * return confirm('Submit these values?\n\n'+$.param(vars));
+ * }
+ *
+ * $('*').myvars().putForm('#mytarget',precb,null,'myhandler.php');
+ *
+ * @param target arg for the target id element to render
+ * @param pre_cb callback function before submission
+ * @param post_cb callback after any results are returned
+ * @param url form action override
+ * @param mth form method override
+ * @return "this" object
+ * @see form(), getForm(), load(), xml()
+ * @author Mark Constable (markc@renta.net)
+ * @author G. vd Hoven, Mike Alsup, Sam Collett
+ * @version 20060606
+ */
+$.fn.putForm = function(target, pre_cb, post_cb, url, mth) {
+ if (pre_cb && pre_cb.constructor == Function)
+ if (pre_cb(this.vars) === false)
+ return;
+
+ var f = this.get(0);
+ var url = url || f.action || '';
+ var mth = mth || f.method || 'POST';
+
+ if (target && target.constructor == Function) {
+ $.xml(mth, url, $.param(this.vars), target);
+ } else if (target && target.constructor == String) {
+ $(target).load(url, this.vars, post_cb);
+ } else {
+ this.vars.push({name: 'evaljs', value: 1});
+ $.xml(mth, url, $.param(this.vars), function(r) { eval(r.responseText); });
+ }
+
+ return this;
+}