Dynamically create text in dialog box

dialog, jquery, jquery-ui

Solution

For best practice, try putting a div inside your dialog div and appending text to that instead.

<div id="myDialog"><div id="myDialogText"></div></div>

and then setting the text of the internal Div. This make for better separation, so you have

- a div for dialog manipulation

- and a div for text display

You can then set the text with

jQuery("#myDialogText").text("your text here");

Problem

How can I dynamically set the text of the dialog box that I'm opening? I've tried a few different things but they all respond with an empty dialog box. Here is my current try: ``` $('#dialog').text('Click on the link to download the file:'.data); $('#dialog').dialog("open"); ```

Original source

Related problems