Skip to content

Instantly share code, notes, and snippets.

@robjcordes
Created September 27, 2012 21:20
Show Gist options
  • Save robjcordes/3796537 to your computer and use it in GitHub Desktop.
Save robjcordes/3796537 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) {
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