tags:

views:

255

answers:

3

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");
A: 

Use the plus symbol to concatenate strings:

$('#dialog').text('Click on the link to download the file:
' + data);
$('#dialog').dialog("open");
Mike
A: 

dialog("open"); isn't a valid jquery UI method. (And what Mike said about concatenating with + instead of .

Check the documentation.

idrumgood
from the docs $(foo).dialog('open') - http://jqueryui.com/demos/dialog/
acedanger
+1  A: 

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

$("#myDialogText").text("your text here");
Evildonald
worked perfectly. thanks for the help!
acedanger
you are most welcome :)
Evildonald