Skip to content

Commit

Permalink
Merge pull request layui#10 from yoder/master
Browse files Browse the repository at this point in the history
增加setContent方法.
  • Loading branch information
贤心 authored Mar 20, 2017
2 parents b6ceae2 + b84b003 commit 687d2c1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/lay/modules/layedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 687d2c1

Please sign in to comment.