無法進入KindEditor.ready(function(){})的解決辦法


最近嘗試用 nodeJS + angularJS + express 開發一個簡單的文章管理系統項目。

 

發布文章采用的是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 id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />'+a;for(var g=0,h=d.childNodes.length;g<h;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[name="content"]', {
            width: '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,{
            width: '780px',
            height: '700px',
            resizeMode: 0,
            allowPreviewEmoticons: false,
            items: [
                'bold', 'italic', 'underline',
                '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|', 'emoticons', 'link']
        });
    }

    $(function(){
        kedit('textarea[name="content"]');
    })

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM