/** * 角色管理的单例 */ var Html = { layerIndex: -1, domId: '', dataId: null, type: 1 }; var editor = null; Html.cutover = function(type, e){ if(typeof type != 'undefined' && null != type){ Html.type = type; } if(null != e){ $('.nav-tabs li').removeAttr('class'); $(e).attr('class', 'active'); } Html.queryData(); } Html.queryData = function(){ $.ajax({ url: Feng.ctxPath + '/html/queryHtml', type: 'POST', data:{ type: Html.type }, success: function (res) { if(res.code == 200){ editor.ready(function() { editor.setContent(res.data) }); }else{ Feng.error(res.msg); } } }); } Html.submit = function(){ $.ajax({ url: Feng.ctxPath + '/html/saveHtml', type: 'POST', data:{ type: Html.type, content: editor.getContent() }, success: function (res) { if(res.code == 200){ Feng.success("保存成功"); }else{ Feng.error(res.msg); } } }); } $(function () { editor = UE.getEditor('editor'); // 手动指定上传文件调用的接口(不同文件类型不同接口) UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl; UE.Editor.prototype.getActionUrl = function(action) { // 这里很重要,很重要,很重要,要和配置中的imageActionName值一样 if(action == 'uploadimage'){ // 这里调用后端我们写的图片上传接口 return '/ueditor/uploadImageData'; }else if(action == 'uploadfile'){ return '/ueditor/uploadFileData'; }else{ return this._bkGetActionUrl.call(this, action); } } Html.queryData(); });