Skip to content

Instantly share code, notes, and snippets.

@robjcordes
Created September 27, 2012 21:20

Revisions

  1. robjcordes created this gist Sep 27, 2012.
    35 changes: 35 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    $(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;
    });
    });
    }
    }