From b84b003995e0386f7c946d7f7332b8bb78d84028 Mon Sep 17 00:00:00 2001 From: yoder Date: Mon, 26 Dec 2016 15:35:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0setContent=E6=96=B9=E6=B3=95.?= =?UTF-8?q?=20/**=20=20*=20=E8=AE=BE=E7=BD=AE=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E5=86=85=E5=AE=B9=20=20*=20@param=20{[type]}=20index=20=20=20?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E7=B4=A2=E5=BC=95=20=20*=20@param?= =?UTF-8?q?=20{[type]}=20content=20=E8=A6=81=E8=AE=BE=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9=20=20*=20@param=20{[type]}=20flag=20=20=20?= =?UTF-8?q?=20=E6=98=AF=E5=90=A6=E8=BF=BD=E5=8A=A0=E6=A8=A1=E5=BC=8F=20*/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lay/modules/layedit.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lay/modules/layedit.js b/src/lay/modules/layedit.js index d81553e..659f5af 100644 --- a/src/lay/modules/layedit.js +++ b/src/lay/modules/layedit.js @@ -107,7 +107,22 @@ layui.define(['layer', 'form'], function(exports){ if(!iframeWin[0]) return; return $(iframeWin[0].document.body).text(); }; - + /** + * 设置编辑器内容 + * @param {[type]} index 编辑器索引 + * @param {[type]} content 要设置的内容 + * @param {[type]} flag 是否追加模式 + */ + Edit.prototype.setContent = function(index, content, flag){ + var iframeWin = getWin(index); + if(!iframeWin[0]) return; + if(flag){ + $(iframeWin[0].document.body).append(content) + }else{ + $(iframeWin[0].document.body).html(content) + }; + layedit.sync(index) + }; //将编辑器内容同步到textarea(一般用于异步提交时) Edit.prototype.sync = function(index){ var iframeWin = getWin(index);