* @class jQuery.plugin.getAttrs
*/
+function serializeControls( controls ) {
+ var i, data = {}, len = controls.length;
+
+ for ( i = 0; i < len; i++ ) {
+ data[ controls[i].name ] = controls[i].value;
+ }
+
+ return data;
+}
+
/**
* Get the attributes of an element directy as a plain object.
*
* @return {Object}
*/
jQuery.fn.getAttrs = function () {
- var i,
- map = this[0].attributes,
- attrs = {},
- len = map.length;
-
- for ( i = 0; i < len; i++ ) {
- attrs[ map[i].name ] = map[i].value;
- }
+ return serializeControls( this[0].attributes );
+};
- return attrs;
+/**
+ * Get form data as a plain object mapping form control names to their values.
+ *
+ * @return {Object}
+ */
+jQuery.fn.serializeObject = function () {
+ return serializeControls( this.serializeArray() );
};
/**
baseHref = $form.attr( 'action' );
baseHref += baseHref.indexOf( '?' ) > -1 ? '&' : '?';
- linkParams = {};
- $.each( $form.serializeArray(), function ( idx, obj ) {
- linkParams[ obj.name ] = obj.value;
- } );
+ linkParams = $form.serializeObject();
return {
textParam: context.data.$textbox.attr( 'name' ),