0

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.

Any thought please?

1 Answer 1

2

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');
Sign up to request clarification or add additional context in comments.

1 Comment

Of course it worked. I love you pal. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.