Below is a consolidated serialize method to accommodate the optimized
vs. semantic issue we've been pursuing recently. Essentially, this is
Matt Grimm's fastSerialize method with conditional behavior to drive
the semantic logic. I like how Matt wrote that method and the
semantic stuff drops right in with minor changes.
I've re-written the form plugin to use this and changed the invoking
methods. Unfortunately I can't post it from inside my firewall at the
moment. In a nutshell, the changes boil down to adding a 'semantic'
arg to each method and passing that arg along to 'serialize'.
Mike
jQuery.fn.serialize = function(semantic) {
var a = [];
if (semantic) {
var ok = {input:true, textarea:true, select:true, button:true};
var jq = jQuery('*', this).not('option');
}
else {
var jq = jQuery('input,textarea,select,button', this);
}
jq.each(function() {
if (semantic && !ok[this.nodeName.toLowerCase()])
return;
var n = this.name;
var t = this.type;
if ( !n || this.disabled || t == 'reset' ||
(t == 'checkbox' || t == 'radio') && !this.checked ||
(t == 'submit' || t == 'image' || t == 'button') &&
this.form.clicked != this ||
this.tagName.toLowerCase() == 'select' && this.selectedIndex == -1)
return;
if (t == 'image' && this.form.clicked_x)
return a.push(
{name: n+'_x', value: this.form.clicked_x},
{name: n+'_y', value: this.form.clicked_y}
);
if (t == 'select-multiple') {
jQuery('option:selected', this).each( function() {
a.push({name: n, value: this.value});
});
return;
}
a.push({name: n, value: this.value});
});
return a;
};
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/