3

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

1 Answer 1

3

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
    });
})
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, but that isn't working and I'm guessing it's because of stackoverflow.com/questions/16490657/…
No you can alse append Html dynamically and use popup. but you need to confirm that use popup bind after append html.
You first have to append your html. then bind dialog function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.