程式碼控制 textarea 控制元件是否為KindEditor 編輯框

SunRain117發表於2014-09-04

  <script charset="utf-8" src="<%:Url.Content("~/UI/Scripts/KindEditor/kindeditor.js") %>"></script>
    <script charset="utf-8" src="<%:Url.Content("~/UI/Scripts/KindEditor/lang/zh_CN.js") %>"></script>
    <script charset="utf-8" src="<%:Url.Content("~/UI/Scripts/KindEditor/prettify.js") %>"></script>

<script>

  function LoadEditor(TextName) {
            var editor = KindEditor.create('textarea[name="' + TextName + '"]', {
                uploadJson: "/fileManagerJson/Index",
                fileManagerJson: '/fileManagerJson/DistanceIndex',
                allowFileManager: false,
                resizeType: 1,
                items: ['undo', 'redo', '|', 'cut', 'copy', 'paste', '|', 'selectall', 'forecolor', 'bold', 'image', 'multiimage'],              
                autoHeightMode: true,
                afterCreate: function () {
                    this.loadPlugin('autoheight');
                },
                afterChange: function () {
                    this.sync();
                },
                afterBlur: function () {
                    this.sync();
                }
            });
            return editor;
        }

 

 

  $(function () {
            $("#aRefused").click(function () { //為激發事件
                $.ajax({
                    type: "POST",
                    url: "/Shared/OrderBackPop",
                    success: function (data) {
                        $("body").eq(0).append(data);//data返回的是html程式碼
                        var arrEditor = $("textarea[name='resonContent']");
                        $.each(arrEditor, function () {
                            // 載入編輯器
                            LoadEditor($(this).attr('name'));
                        });
                    }

                });
            });
        });
    </script>

 

相關文章