无法进入KindEditor.ready(function(){})的解决办法-飞外

发布文章采用的是KindEditor编辑器,一直用这个编辑器感觉还不错,官方文档的使用说明也很详细。然而,今天遇到了个奇葩问题,kindeditor-min.js以及css文件明明已经加载进来了,却进入不了KindEditor.ready(function(K){})里面。用以下代码测试了一下:

 console.log(KindEditor); console.log(KindEditor.ready());

控制台输出:

function (a,b){function c(a){a[0]||(a=[]);return new D(a)}if(!(a===i||a===null)){if(typeof a==="string"){b (b=f(b)[0]);var d=a.length;a.charAt(0)==="@" (a=a.substr(1));if(a.length!==d||/ .+ /.test(a)){var d=(b?b.ownerDocument||b:document).createElement("div"),e=[];d.innerHTML=' img  width="0" height="0" / for(var g=0,h=d.childNodes.length;g g++){var j=d.childNodes[g];j.id!="__kindeditor_temp_tag__" e.push(j)}return c(e)}return c(Ca(a,b))}if(a a.constructor===D)return a;a.toArray (a=a.toArray());if(Z(a))return c(a);return c(Ja(arguments))}}undefined

说明KindEditor确实是已经定义了的。

后来换了一种方式来初始化创建编辑器,突然就好了。。不知道为什么会这样。。

原来的代码:

 KindEditor.ready(function(K) { alert("aa"); window.editor = K.create('textarea[]', { '1000px', height: '1500px', resizeMode: 0, allowPreviewEmoticons: false, items: [ 'bold', 'italic', 'underline', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'link']

不能弹出“aa”

修改后的代码:

 function kedit(kedit){ var editor = KindEditor.create(kedit,{ '780px', height: '700px', resizeMode: 0, allowPreviewEmoticons: false, items: [ 'bold', 'italic', 'underline', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'link'] $$(function(){ kedit('textarea[]');