data('title.dialog', 'new title') not working
Hi,
I read the forum and found this syntax to change my dialog box title after it has been initialized:
- $('#myDialog').data('title.dialog', 'new title')
However, it doesn't work for me.
I'm using jQuery 1.4.2 and jQuery UI 1.8.
Here is my very simple page:
- <html>
- <head>
- <title>Dialog box test</title>
- <link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.custom.css" />
- <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
- <script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"></script>
- <script type="text/javascript">
- function showDialog(title) {
- if (title)
- $('#dialog').data('title.dialog', title);
- $('#dialog').dialog('open');
- }
- $(function() {
- $('#dialog').dialog({
- autoOpen: false,
- modal: true
- });
- });
- </script>
- </head>
- <body>
- <div id="dialog" title="foo"></div>
- <input type="button" value="foo" onclick="showDialog()" />
- <input type="button" value="bar" onclick="showDialog('bar')" />
- </body>
- </html>
I delved into the code with the Chrome debugger and from what I understood, the title is indeed changed on the cached object.
But then, when the dialog box opens, its title is not changed.
Did I miss anything? Do I use data() the wrong way?
Thanks for your help!