function dialog(title, message) {
    this.elem = $('<div></div>')
        .html(message)
        .dialog({
            autoOpen: false,
            title: title,
            close: function() {
                $(this).remove();
            }
        });
}
dialog.prototype = {
    show: function() {
        this.elem.dialog('open');
    }
};

usage:
var d = new dialog('foo', 'bar');
d.show();


On Aug 27, 9:50 am, Svebor <[email protected]> wrote:
> I'm trying to write a class that would allow me to do this:
>
> var dialog = new v2dialog("Title", "Dialog message.");
> test.show();
>
> This code creates a new dom element (<div>) and creates a new jQuery
> dialog from it (ideally).
> After the dialog is closed, the dom element is destroyed.
>
> These are parts of the js class that I've written to no avail:
>
> this.createDOMElement = function() {  //should create a dom <div>
> element with required id
>         this.domElement = document.createElement("div");
>         this.domElement.setAttribute("id", this.elementID);
>         this.domElement.setAttribute("title", this.title);
>         this.domElement.innerHTML = this.message;
>
> }
>
> this.show = function(){  //should create the dialog from the given
> element's ID
>         var dE = this.elementID;      //id of the dom element which we
> want to become a dialog
>         var dO = this.dialog_options;//options array for dialog
> constructor
>         $(function(){
>             dE = "#"+dE;
>             $(dE).dialog(dO);
>         });
>
> }
>
> I'd appreciate any help...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to