data('title.dialog', 'new title') not working

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:
  1. $('#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:
  1. <html>
  2.     <head>
  3.         <title>Dialog box test</title>
  4.         <link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.custom.css" />
  5.         <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
  6.         <script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"></script>

  7.         <script type="text/javascript">

  8.         function showDialog(title) {
  9.             if (title)
  10.                $('#dialog').data('title.dialog', title);

  11.            $('#dialog').dialog('open');
  12.         }

  13.         $(function() {
  14.             $('#dialog').dialog({
  15.                 autoOpen: false,
  16.                 modal: true
  17.             });
  18.         });

  19.         </script>
  20.     </head>
  21.     <body>
  22.           <div id="dialog" title="foo"></div>

  23.           <input type="button" value="foo" onclick="showDialog()" />
  24.           <input type="button" value="bar" onclick="showDialog('bar')" />
  25.     </body>
  26. </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!