immayankmodi
immayankmodi

Reputation: 8600

How to open UI Dialog on each function call?

I want to open dialogbox each time when OpenDialog() method calls each time with its contents.

Function:

function OpenDialog(){
    $("#seeContent").dialog({
                autoOpen: "false",
                stack: "true",
                height: "600",
                width: "700",
                resizable: "false"
            });
}

Function call:

<input type="button" onclick="OpenDialog()">

Note: It works fine while first call, when second call it overrides the first one.

Upvotes: 0

Views: 247

Answers (2)

immayankmodi
immayankmodi

Reputation: 8600

The clone() helps me to create a copy of dialog. Following is my working code.

jQuery("#seeContent").clone().dialog(
            { autoOpen: "false",
              stack: "true",
              height: "600",
              width: "700",
              resizable: "false" }
  });

I posted this answer because i could help others.

Hope, it will helps you. Thanks. !!

Upvotes: 0

bobthyasian
bobthyasian

Reputation: 943

HTML:

<input type="button" id="open_dialog">
<div id="content"></div>

JS:

$('#open_dialog').click(function(){
var data = getData();     //Get new data
$('#content').html(data); //Replace old data
$('#content').dialog({    //Open dialog
     autoOpen: "false",
     stack: "true",
     height: "600",
     width: "700",
     resizable: "false"
    });
});

Essentially, every time you click to open the dialog new data should be loaded first then open the dialog.

Upvotes: 1

Related Questions