title: jQuery UI dialog - add handler for custom button
body: <p>I added a custom button to my jQuery UI dialog titlebar, as follows:</p>
  
  <pre><code>$('#dialog').html(html);
  $('#dialog').dialog({
      modal: true,
      open: function(event, ui) {
          $(".ui-dialog-titlebar").append("&lt;a href=\"#variants\" id=\"variants-button\"&gt;&lt;img src=\"admin-images/variants-button.png\" alt=\"Variants\" /&gt;&lt;/a&gt;");
      }
  });
  </code></pre>
  
  <p>Now I need to add a 'click' handler to this button, but I am struggling with this.</p>
  
  <pre><code>$('#variants-button').click(function(){
      $('#information').hide();
      $('#variants').show();
      return false;
  });
  </code></pre>
  
  <p>This doesn't do anything. I have also tried putting the click handler in a 'delegate' but that doesn't work either. Any ideas?</p>
  
  <p>EDIT: zysoft has provided the correct solution, but I need this to work with multiple dialogs on the page. It does not seem to work as expected with multiple dialogs.</p>