- // Skip non-selected nodes
- if ((this.parentNode.nodeName == 'SELECT') && (!this.selected))
- return;
-
- // Skip non-checked nodes
- if (((this.type == 'radio') || (this.type == 'checkbox')) && (!this.checked))
- return;
-
- // If we come here, everything is fine, so add the data
- a.push({
- name: this.name || this.id || this.parentNode.name || this.parentNode.id,
- value: this.value
- });
- });
-
- // Add submit button if needed
- if (sButton && (sButton !== null))
- a.push({ name: sButton, value: 'x' });
-
- return a;
-};
-
-/**
- * name: $.fn.update
- * example: $('someJQueryObject').update('sURL', 'sAction', 'aValues', 'fCallback');
- * docs: Calls sURL with sAction and sends the aValues
- * Puts the results from that call in the jQuery object and calls fCallback
- */
-$.fn.update = function(sURL, sMethod, aValues, fCallback) {
- var el = this;
-
- // Process
- $.xml(
- sMethod || "GET",
- sURL || "",
- $.param(aValues),
- function(sResult) {
- sResult = $.httpData(sResult);
-
- // Update the element with the new HTML
- el.html(sResult);
-
- // Evaluate the scripts AFTER this (so you can allready modify the new HTML!)
- el.html(sResult).find("script").each(function(){
- try { $.eval( this.text || this.textContent || this.innerHTML ); } catch(e) { }
- });
-
- // And call the callback handler :)
- if (fCallback && (fCallback.constructor == Function))
- fCallback();
- }
- );
-};
-
-/**
- * name: $.fn.serialize
- * example: $('someJQueryObject').serialize('sButton', 'fCallback');
- * docs: Calls the form's action with the correct method and the serialized values.
- * Optionally adds the button which is clicked if you provide it.
- * When there are results, the fCallback function is called.
- */
-$.fn.serialize = function(sButton, fCallback) {
- var el = this.get(0);
-
- // Process
- $.xml(
- el.method || "GET",
- el.action || "",
- $.param(this.formValues(sButton)),
- function(sResult) {
- if (fCallback && (fCallback.constructor == Function))
- fCallback($.httpData(sResult));
- }
- );
-};