title: jquery close dialog
body: <p>I wanna close a jquery modal dialog with a button that is within a form inside the modal... </p>
  
  <pre><code>$("#btnCancel").button().on('click', function (event) {
      event.preventDefault();
      $("#modalDlgWindow").dialog("close");
  });
  
  function loadDialog(tag, event, target) {
      event.preventDefault();
      event.stopPropagation();
      var $loading = $('&lt;img src="../../Content/assets/images/nivo-loader.gif" alt="loading" class="ui-loading-icon"&gt;');
      var $url = $(tag).attr('href');
      var $title = $(tag).attr('title');
      $("#modalDlgWindow").empty();
      $("#modalDlgWindow")
          .append($loading)
          .load($url)
          .dialog({
              autoOpen: false
              , resizable: false
              , autoResize: true
              , title: $title
              , width: 'auto'
              , modal: false
              , height: 'auto'
              , show: 'fade'
              , position: [10, 50]
              , hide: 'fade'
          });
      $("#modalDlgWindow").dialog('open');
  };
  </code></pre>
  
  <p>It works with <code>.fadeOut(500)</code> and <code>.empty()</code> and so I thought that it would also work with <code>.dialog('close')</code> but it doesn't. Does anyone have a solution to my problem please?</p>