您的位置:首页 > 运维架构

百度编辑器添加监控内容改变事件,不要放在editor.read()里面

2014-11-10 17:45 495 查看
百度编辑器添加监控内容改变事件,不要放在editor.read(function(){   })里面,否则显示内容时,没有上面的工具栏,要在编辑器里按个空格符什么的才出来

function add_change_listener(shellId){
//编辑内容改变监听事件
//var shellId = 'container';

// editor.addListener("contentChange",function(){
// console.log('内容改变:'+editor.getContent());
// });
//一般的字符都可以监听,但是@#¥%……这些字符的输入是监听不到的。所以采用如下的方法:
//参考帖子:http://www.cnblogs.com/longze/archive/2013/07/17/3195564.html

$('#' + shellId + ' #edui1_toolbarbox').css('display','none');
editor.fireEvent("contentChange");

var $textarea = $('#' + shellId + '').parent().find('iframe').contents();

var fn = function(){
g_content_changed = true;
console.log('content_changed1, g_content_changed='+g_content_changed);
}

if (document.all) {
$textarea.get(0).attachEvent('onpropertychange',function(e) {
fn();
});
}else{
$textarea.on('input',fn);
$textarea.on('keyup',fn);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  编辑器 百度