浏览代码

Multiline message supported

Dante 12 年之前
父节点
当前提交
97fe097fd9
共有 2 个文件被更改,包括 24 次插入8 次删除
  1. 12 4
      examples/assets/bootstrap-dialog/js/bootstrap-dialog.js
  2. 12 4
      js/bootstrap-dialog.js

+ 12 - 4
examples/assets/bootstrap-dialog/js/bootstrap-dialog.js

@@ -147,12 +147,20 @@ var BootstrapDialog = null;
             return this;
         },
         createDynamicContent: function(rawContent) {
-            var contentType = typeof rawContent;
-            if (contentType === 'function') {
-                return rawContent.call(rawContent, this);
+            var content = null;
+            if (typeof rawContent === 'function') {
+                content = rawContent.call(rawContent, this);
+            } else {
+                content = rawContent;
+            }
+            if (typeof content === 'string') {
+                content = this.formatStringContent(content);
             }
 
-            return rawContent;
+            return content;
+        },
+        formatStringContent: function(content) {
+            return content.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />');
         },
         setData: function(key, value) {
             this.options.data[key] = value;

+ 12 - 4
js/bootstrap-dialog.js

@@ -147,12 +147,20 @@ var BootstrapDialog = null;
             return this;
         },
         createDynamicContent: function(rawContent) {
-            var contentType = typeof rawContent;
-            if (contentType === 'function') {
-                return rawContent.call(rawContent, this);
+            var content = null;
+            if (typeof rawContent === 'function') {
+                content = rawContent.call(rawContent, this);
+            } else {
+                content = rawContent;
+            }
+            if (typeof content === 'string') {
+                content = this.formatStringContent(content);
             }
 
-            return rawContent;
+            return content;
+        },
+        formatStringContent: function(content) {
+            return content.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />');
         },
         setData: function(key, value) {
             this.options.data[key] = value;