Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pass dialog title variable in jQuery Dialog

I need to pass the title of the jQuery dialog variably.

I am trying to use the "data" property like this:

jQuery( "#dialog" ).data( 'the_title', 'John Doe Dialog' ).dialog( "open" );
    
jQuery( function() {

    jQuery( "#dialog" ).dialog({       

        title: jQuery( "#dialog" ).data( 'the_title' ), 

    });

});

But it is not working, it is displaying the default title.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any thought please?

>Solution :

You can directly specify any of the dialogue options documented here,
title being one such, I’ve added another couple of options as further examples.

jQuery( "#dialog" ).dialog({
    title: 'John Doe Dialog',
    width: '100px',
    height: '50px'
});

You can also specify any option after the dialog is created

$('#dialog').dialog();
$('#dialog').dialog('option', 'title', 'wibble');

hence you can use this chaining style of code:

$('#dialog').dialog().dialog('option', 'title', 'wibble');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading