Reputation: 403
I'm creating a form using javascript
which is actually a modal dialog.
I'm having trouble figuring out how to attach an id
tag when I try to set it up.
This is how I'm creating the line in js
tmpString += "<div id=\"dialog-modal\" class=\"widget-dialog-container\" title=\"Complete Your Order\">";
...
...
var handle = document.getElementById('content');
handle.innerHTML = tmpString;
Now I'm trying to access it this way
$(document).dialog( {
height: 800,
width: 800,
modal: true,
autoOpen: false
});
I do know that I have to have $(document)
because the dialog is being created in code. but I don't know how to give it the #dialog-modal
so I can access it. Any help would be greatly appreciated. Thanks
Upvotes: 3
Views: 1002
Reputation: 3832
You need to call your popup like this
$("#dialog-modal").dialog( {
height: 800,
width: 800,
modal: true,
autoOpen: false
});
at any time use
$("#dialog-modal").dialog("open");
to open it.
Dynamic html popup append
$(document).ready(function () {
var tmpString = "<div id=\"dialog-modal\" class=\"widget-dialog-container\" title=\"Complete Your Order\">";
var handle = document.getElementById('content');
handle.innerHTML = tmpString;
$("#dialog-modal").dialog({
height: 800,
width: 800,
modal: true,
autoOpen: false
});
})
Upvotes: 3