diff --git a/addon/dialog/dialog.js b/addon/dialog/dialog.js
index ced394d3fca9b535eee8e4278757da31e93e6579..499964fdb2c7be7e949ff3cf120e03df699ad071 100644
--- a/addon/dialog/dialog.js
+++ b/addon/dialog/dialog.js
@@ -10,7 +10,11 @@
     } else {
       dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
     }
-    dialog.innerHTML = template;
+    if (typeof template == "string") {
+      dialog.innerHTML = template;
+    } else { // Assuming it's a detached DOM element.
+      dialog.appendChild(template);
+    }
     return dialog;
   }
 
diff --git a/doc/manual.html b/doc/manual.html
index 80de6d950f29d4dd7529438a8debcf347ebe7686..8100bb82a7382e9df712534be2abb35d7d55e21f 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -1710,9 +1710,9 @@
       <dd>Provides a very simple way to query users for text input.
       Adds an <strong><code>openDialog</code></strong> method to
       CodeMirror instances, which can be called with an HTML fragment
-      that provides the prompt (should include an <code>input</code>
-      tag), and a callback function that is called when text has been
-      entered. Also adds
+      or a detached DOM node that provides the prompt (should include
+      an <code>input</code> tag), and a callback function that is called
+      when text has been entered. Also adds
       an <strong><code>openNotification</code></strong> function that
       simply shows an HTML fragment as a notification. Depends
       on <code>addon/dialog/dialog.css</code>.</dd>