Skip to content

Instantly share code, notes, and snippets.

@jdkealy
Forked from robjcordes/gist:3796537
Created September 27, 2012 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdkealy/3796561 to your computer and use it in GitHub Desktop.
Save jdkealy/3796561 to your computer and use it in GitHub Desktop.
$(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