Dynamic Dialog Headers

var dlg = $("#dialog").dialog({ autoOpen: false, modal: true, buttons: { 'Update': function() { alert(clientCode); }, Cancel: function() { $(this).dialog('close'); } } }); $(".edit").click(function() { myval = $(this).parent().children('td:nth-child(1)').text(); dlg.dialog('open'); return false; }); 

How can I take "myval" and have it as the name of the dialog box? I tried passing it as an argument when doing dlg.dialog('open', myval) and with no luck. I also tried passing it as a parameter, but no luck. I'm probably doing something wrong.

+6
jquery-ui
source share
2 answers

create a dialog in the click event and use it to set the title:

something like that:

 $(".edit").click(function() { myval = $(this).parent().children('td:nth-child(1)').text(); var dlg = $("#dialog").dialog({ autoOpen: false, title: myval, modal: true, buttons: { 'Update': function() { alert(clientCode); }, Cancel: function() { $(this).dialog('close'); } } }); dlg.dialog('open'); return false; }); 
+4
source share
 $("#your-dialog-id").dialog({ open: function() { $(this).dialog("option", "title", "My new title"); } }); 
+8
source share

All Articles