|
Re: [jQuery] Form plugin revisited ;-): msg#01153lang.javascript.jquery
Jörn, I see negligible performance gains using $(:input, ctx) vs the current $('*:not(option)', ctx), however it does make the code cleaner because I can get rid of the 'ok' array. formToArray now looks like this: jQuery.fn.formToArray = function(semantic) { var a = []; var q = semantic ? ':input' : 'input,textarea,select,button'; jQuery(q, this).each(function() { 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 && this.form.clk != this || this.tagName.toLowerCase() == 'select' && this.selectedIndex == -1) return; if (t == 'image' && this.form.clk_x != undefined) return a.push( {name: n+'_x', value: this.form.clk_x}, {name: n+'_y', value: this.form.clk_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; };
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [jQuery] $(document).load() and friends, Dave Methvin |
|---|---|
| Next by Date: | [jQuery] The index of an element with Event, BoOz |
| Previous by Thread: | Re: [jQuery] Form plugin revisited ;-), "Jörn Zaefferer" |
| Next by Thread: | Re: [jQuery] Form plugin revisited ;-), Jörn Zaefferer |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |