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");
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
You can then set the text with
jQuery("#myDialogText").text("your text here");
Here is an alternative way of creating dialogs on the fly and setting their messages dynamically:
$('<div></div>').dialog({
modal: true,
title: "Confirmation",
open: function() {
var markup = 'Hello World';
$(this).html(markup);
},
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
} }); //end confirm dialog
See it in action: http://jsfiddle.net/DYbwb/
Use the plus symbol to concatenate strings:
$('#dialog').text('Click on the link to download the file:
' + data);
$('#dialog').dialog("open");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With