0

I have this variable template="<div>...</div>"

I want show this html code inside a dialog:

<div id="dialog" title="Basic dialog">
    <p id="templates"></p>
</div>

<script>
    $("#templates").html(template);
    $( "#dialog" ).dialog({
       height: auto,
       width: 800,
       modal: true,
       // ...
    });
</script>

But it doesn't work.

How I can append my custom html inside a dialog?

3
  • 1
    You are trying to add "<html><head>...</head></html>" into <p>. Are you serious? You can use <iframe> for this. Or maybe more simplified (just <body> inner HTML) template and <div> instead of <p>. Commented Oct 30, 2014 at 13:36
  • "I have this variable template="<html><head>...</head></html>" I want show this html code inside a dialog:" No, you don't want that. I think you've misunderstood what you're trying to accomplish a bit. Commented Oct 30, 2014 at 14:07
  • @Regent I am wrong...thx...;)!!! Commented Oct 30, 2014 at 14:12

3 Answers 3

2

This should work for your purposes:

function PopModal(StuffToAppearInModal) {
              $('<div>' + StuffToAppearInModal+ '</div>').dialog({
              height: auto,
              width: 800,
              modal: true,
                });
            }

remove the "head" and "html" tags from your variable, and call it like this:

 PopModal("hey this is going to appear in my <font color='Red'>modal</font>.  html controls work, too like this: <input type='text' id='tbTest'/>");
Sign up to request clarification or add additional context in comments.

Comments

0

You can use wireframes or append code without <html><head>...</head></html> because it is determined as web page.

Comments

0

Only valid html content will be interpreted as parameter inside html function. If not, it will be filtered. In your example filter only leaves "..." in your content.

See example for other (valid) html content.

var template="<table style=\"border:solid red 2px;\"><tr><td><u>Test</u></td></tr></table>";
$("#templates").html(template);
...

Comments

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.