title: What's the best practice to add default function to jQuery Dialog open/close events?
body: <p>I'm trying to define some default behaviours for my jQuery Dialogs like the following:</p>
  
  <pre><code>(function($) {
          /**
           * Overriding default options
           **/
          $.ui.dialog.defaults.bgiframe = true;
          $.ui.dialog.defaults.open = function() {
              if ($('.ui-widget-overlay').length == 0) return;
              if ($.browser.msie) {
                  // scrollbar fix for IE
                  $('html').css('overflow-y','hidden');
                  $('html').css('overflow-x','hidden');
              } else {
                  // disable scrollbar for other browsers
                  $('body').css('overflow','hidden');
              }
          };
          $.ui.dialog.defaults.beforeclose = function(event, ui) {
              if ($('.ui-widget-overlay').length == 0) return;
              if ($.browser.msie) {
                  // scrollbar fix for IE
                  $('html').css('overflow-y','auto');
                  $('html').css('overflow-x','auto');
              } else {
                  // disable scrollbar for other browsers
                  $('body').css('overflow','auto');
              }
          };
  })(jQuery);
  </code></pre>
  
  <p>The above works when I have no custom open/beforeclose function specified when the dialog is created. So I'm wondering what is the best practice to add these functionality into all my dialogs, while preserving the ability to specify open/beforeclose functions.</p>