-
-
Save jdkealy/3796561 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
idonate.loadForm('.form-container'); | |
}); | |
idonate = { | |
postNode : function(){ | |
}, | |
serialize : function(){ | |
var o = {}; | |
var a = this.serializeArray(); | |
$.each(a, function() { | |
if (o[this.name] !== undefined) { | |
// push is for arrays... and why is push being used in a condition? what are you testing for? | |
// to make o and array you would say o = []; | |
// but you made o and object when you did this {}; | |
if (!o[this.name].push) { | |
o[this.name] = [o[this.name]]; | |
} | |
o[this.name].push(this.value || ''); | |
} else { | |
o[this.name] = this.value || ''; | |
} | |
}); | |
return o; | |
}, | |
loadForm : function(div){ | |
var that = this; | |
$(div).load('/sites/all/modules/idonate_custom/services-demo-form.html', function(){ | |
$('form#services-demo').submit(function() { | |
var test = $('form#services-demo').that.serialize(); // that is undefined | |
$('#result').text(JSON.stringify(test)); | |
return false; | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment