JavaScript objects and persistence through dialogs
Rather simple question here. I want to create an JS object that has a property, say, name. I want to create that object and be able to use it throughout my page. For example, what I have now doesn't work:

    var item = new Object();
    function makeItem(title) { 
       item.name = title;
    }

Inside a modal dialog:

    makeItem("test");
    alert(item.name); // returns "test"

Once I close the dialog, however, all of the information related to `item` is gone. For example, I can't go ahead and see if `item.name` contains anything the next time I try to create the same dialog. 

Nothing is currently inside a document.ready().

Clearly I'm not fully capturing the idea of the DOM. S|O, would you mind enlightening my poor brain?

Thanks!
JavaScript objects and persistence through dialogs
===

Rather simple question here. I want to create an JS object that has a property, say, name. I want to create that object and be able to use it throughout my page. For example, what I have now doesn't work:

    var item = new Object();
    function makeItem(title) { 
       item.name = title;
    }

Inside a modal dialog:

    makeItem("test");
    alert(item.name); // returns "test"

Once I close the dialog, however, all of the information related to `item` is gone. For example, I can't go ahead and see if `item.name` contains anything the next time I try to create the same dialog. 

Nothing is currently inside a document.ready().

Clearly I'm not fully capturing the idea of the DOM. S|O, would you mind enlightening my poor brain?

Thanks!