Commit 3386923d authored by John Resig's avatar John Resig

Fixed some bugs in the serialization code, it seems to work now.

parent f1c8b3ff
...@@ -145,28 +145,23 @@ $.fn.load = function(a,o,f) { ...@@ -145,28 +145,23 @@ $.fn.load = function(a,o,f) {
*/ */
$.fn.formValues = function() { $.fn.formValues = function() {
var a = []; var a = [];
this.find("input,textarea,option") $("input,textarea,option",this).filter(":enabled").each(function(){
.filter(":enabled") // Skip selects with options which are not selected
.each(function() { if ((this.parentNode.type == 'select-one' || this.parentNode.type == 'select-multiple') && !this.selected) {
// return null;
// Skip selects with options which aren't selected }
if (((this.parentNode.type == 'select-one') || (this.parentNode.type == 'select-multiple')) &&
(!this.selected)) // Skip radio and checkbox elements which are not checked
return; if ((this.type == 'radio' || this.type == 'checkbox') && !this.checked) {
return null;
// }
// Skip radio and checkbox elements which aren't checked
if (((this.type == 'radio') || (this.type == 'checkbox')) && // All other elements are valid
(!this.checked)) a.push({
return; name: this.name || this.id || this.parentNode.name || this.parentNode.id,
value: this.value
//
// All other elements are valid ;)
var o = {};
o.name = this.name || this.id || this.parentNode.name || this.parentNode.id;
o.value = this.value;
a.push(o);
}); });
});
return a; return a;
}; };
...@@ -179,11 +174,9 @@ $.fn.formValues = function() { ...@@ -179,11 +174,9 @@ $.fn.formValues = function() {
*/ */
$.update = function(objElement, strURL, arrValues, fncCallback) { $.update = function(objElement, strURL, arrValues, fncCallback) {
$.post(strURL, arrValues, function(strHTML) { $.post(strURL, arrValues, function(strHTML) {
//
// Update the element with the new HTML // Update the element with the new HTML
objElement.html(strHTML); objElement.html(strHTML);
//
// Evaluate the scripts // Evaluate the scripts
objElement.html(strHTML).find("script").each(function(){ objElement.html(strHTML).find("script").each(function(){
try { try {
...@@ -191,7 +184,6 @@ $.update = function(objElement, strURL, arrValues, fncCallback) { ...@@ -191,7 +184,6 @@ $.update = function(objElement, strURL, arrValues, fncCallback) {
} catch(e) { } } catch(e) { }
}); });
//
// Callback handler // Callback handler
if (fncCallback) { fncCallback(); } if (fncCallback) { fncCallback(); }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment