Ferhat Arslan Ferhat Arslan - 1 month ago 5
ASP.NET (C#) Question

How can I generate dynamic popup with html ?

I have a jquery popup :

<div id="dialog-modal" title="Test">
<p>Test</p>
</div>

$("#dialog-modal").dialog({
autoOpen: false,
width: 300,
height: 250,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});

$("#modal-opener").click(function () {
$("#dialog-modal").dialog("open");

});


And I have a html code from db. Example:

ViewBag.Test = "<table><tr><td>Test</td></tr><tr><td>Test 123</td></tr>";


So, I want this html into popup

How Can I do ?

Thank You.

Answer

Need to use .html() before open.

$("#modal-opener").click(function () {       
     $("#dialog-modal").html("<b>New HTML</b>");                               
     $("#dialog-modal").dialog("open");
});
Comments