My web app needs to be able to pull information from a SQL database and create objects based on the information. These are HTML elements that need click events (and other methods associated with them).
What I am currently doing:
function init() {
    //initially creates objects based on SQL database
    //user creates a new Foo
    fooA = new Foo({id: i, otherInfo: "..."});
    $(fooA.selector).click({...});
    $(fooA.selector).draggable({...});
    //etc.
    $(fooA.selector).appendTo('#topContainer');
function Foo(data) {
    this.id = data.id;
    this.html = "";
    this.selector = "#"+this.id;
    $('<div/>',{
        "class": "Foo",
        id: this.id,
        text: 'Blah blah blah'
    })
}
UPDATE: Is there a better way to create HTML div's that have events or is this an efficient, adequate way? And do javascript objects need to be created in an array?
 
    