<script type="text/javascript">
var ue = UE.getEditor('container',{
toolbars:[[
'fullscreen', 'source', '|', 'undo', 'redo', '|',
'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
'directionalityltr', 'directionalityrtl', 'indent', '|',
'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
'emotion', 'scrawl','insertcode','pagebreak', 'template', '|',
'horizontal', 'date', 'time', 'spechars', '|',
'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
'print', 'preview', 'searchreplace', 'help'
]]
});
ue.ready(function() {
//设置编辑器的内容
//获取html内容,返回: <p>hello</p>
var html = ue.getContent();
//获取纯文本内容,返回: hello
var txt = ue.getContentTxt();
$("#pub").click(function(){
var data = $("#content").attr('value',html)
$("#myform").submit()
//发布好内容后可以进行清理ueditor 缓存操作,代码如下
ue.execCommand("clearlocaldata");
})
});
///添加监听,每500毫秒保存一份草稿箱(通过ueditor 自己内置的缓存cookie来保存,已避免误操作关闭页面后丢失编辑好的内容)
setTimeout(function () {
ue.execCommand('drafts');
}, 500);
</script>