diff --git a/js/misc/dialog.ajax.js b/js/misc/dialog.ajax.js
index b12c7e9..b2b03ff 100644
--- a/js/misc/dialog.ajax.js
+++ b/js/misc/dialog.ajax.js
@@ -78,7 +78,8 @@
           width: 0,
           height: 0,
           padding: 0,
-          border: 0
+          border: 0,
+          overflow: 'hidden'
         });
         buttons.push({
           text: $originalButton.html() || $originalButton.attr('value'),
@@ -132,15 +133,19 @@
       response.dialogOptions.buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
     }
 
+    response.dialogOptions = response.dialogOptions || {};
+
+    // Create the dialog object
+    var dialog = Drupal.dialog($dialog.get(0), response.dialogOptions);
+
     // Bind dialogButtonsChange.
     $dialog.on('dialogButtonsChange', function () {
       var buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
       $dialog.modal('option', 'buttons', buttons);
+      dialog.createButtons($dialog, buttons);
     });
 
     // Open the dialog itself.
-    response.dialogOptions = response.dialogOptions || {};
-    var dialog = Drupal.dialog($dialog.get(0), response.dialogOptions);
     if (response.dialogOptions.modal) {
       dialog.showModal();
     }
@@ -221,14 +226,7 @@
 
     // Add new buttons.
     if (settings.buttons && settings.buttons.length) {
-      var $footer = $(Drupal.theme.bootstrapModalFooter('', true)).appendTo($element.find('.modal-content'));
-      for (var i in settings.buttons) {
-        if (!settings.buttons.hasOwnProperty(i)) continue;
-        var button = settings.buttons[i];
-        $('<button class="' + button.class + '">' + button.text + '</button>')
-          .appendTo($footer)
-          .on('click', button.click);
-      }
+      dialog.createButtons($element, settings.buttons);
     }
   });
 
diff --git a/js/misc/dialog.js b/js/misc/dialog.js
index 5a92e82..ae2498d 100644
--- a/js/misc/dialog.js
+++ b/js/misc/dialog.js
@@ -60,7 +60,11 @@
    * @return {Drupal.dialog~dialogDefinition}
    */
   Drupal.dialog = function (element, options) {
+    var elementIsString = typeof element == 'string';
     var $element = $(element);
+    if (elementIsString) {
+      $('body').append(Drupal.theme.bootstrapModal({'title': options.title || ''}));
+    }
 
     function openDialog(settings) {
       settings = $.extend({}, drupalSettings.dialog, options, settings);
@@ -84,6 +88,47 @@
           $(window).trigger('dialog:afterclose', [dialog, $element]);
         })
         .modal('hide');
+
+      if (elementIsString) {
+        window.setTimeout(function() {
+          $element.remove();
+        }, 2000);
+      }
+    }
+
+    function createButtons($element, buttons) {
+      buttons = buttons || options.buttons;
+
+      if (!buttons) {
+        $element.find('.modal-footer-buttons').remove();
+        if ($el = $element.find('.modal-footer').is(':empty')) {
+          $el.remove();
+        }
+        return;
+      }
+
+      var $footer = $element.find('.modal-footer');
+      if (!$footer.length) {
+        $footer = $('<div class="modal-footer-buttons">');
+        $(Drupal.theme.bootstrapModalFooter('', true)).append($footer).appendTo($element.find('.modal-content'));
+      }
+      else {
+        // Remove any existing buttons
+        $footer = $footer.find('.modal-footer-buttons').empty();
+      }
+
+      if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
+        this._removeClass( this.uiDialog, "ui-dialog-buttons" );
+        return;
+      }
+
+      for (var i in buttons) {
+        if (!buttons.hasOwnProperty(i)) continue;
+        var button = buttons[i];
+        $('<button class="' + button.class + '">' + button.text + '</button>')
+          .appendTo($footer)
+          .on('click', button.click);
+      }
     }
 
     var dialog = {
@@ -95,9 +140,11 @@
       showModal: function () {
         openDialog({show: true});
       },
-      close: closeDialog
+      close: closeDialog,
+      createButtons: function($element, buttons) {
+        createButtons($element, buttons);
+      }
     };
-
     return dialog;
   };
 
