kindeditor使用方法

1,首先在html文件中添加一個textarea組件,
<textarea class="form-control" style="width: 100%; height: 150px; margin: 0 auto;" id="content" name="content" rows="10" ng-model="mail.content"></textarea>

2,在js文件中引用該Kindeditor的js文件,定義一個editor,並邦定到html文件中定義的textarea控件,
        var editor=KindEditor.create("textarea[name='content']",{
            allowFileManager:false,
            resizeType:0,
            width:"100%",
            height:"100%",
            uploadJson:"../sendBox/upload",
            afterBlur:function(){
                this.sync();
            }
        });

若是是用在模態對話框中使用kindeditor,須要在顯示前從新動態建立一個,才能正常使用:
        $(".newMail").click(function(){
            $scope.mail={};
            $("#editWind").modal("show");

            var editor=KindEditor.create("textarea[name='content']",{
                allowFileManager:false,
                resizeType:0,
                width:"100%",
                height:"100%",
                uploadJson:"../sendBox/upload",
                afterBlur:function(){
                    this.sync();
                }
            });
        });

若是是在模態對話框中使用kindeditor,須要在隱藏的方法中移除該組件邦定的控件,不然下次顯示時不能正常使用:
        $(".cancel").click(function(){
            $("#editWind").on("hidden",function(){
                KindEditor.remove("#content");
            });
            $("#editWind").modal("hide");
        });html

相關文章
相關標籤/搜索