【问题标题】:Ckseditor with Knockout js binding issue具有 Knockout js 绑定问题的 Ckseditor
【发布时间】:2017-01-13 20:52:57
【问题描述】:

我需要一个富文本区域框来绑定到可淘汰的可观察变量,我尝试使用 Ckseditor 控件,但即使我为 CKSeditor 放置了自定义 KO 绑定,绑定也不起作用。所以我切换回常规的html textarea,然后我可以看到文本的绑定,但是它会显示带有html标签的文本-

<p>This is the scope</p>

我想将 textarea 转换为丰富的 textarea 控件,如 cks 或任何其他控件,有人知道怎么做吗?

<script src="https://cdn.ckeditor.com/4.5.7/standard/ckeditor.js"></script>
<div class="form-group">
                <label for="Scope">Scope</label>
                  <textarea rows="10" name="Scope" class="form-control input-sm" id="Scope" data-bind="value: Scope"></textarea> 
            </div>

以下是 Knockout 可观察变量代码:

 self.Scope = ko.observable("<p>This is the scope</p>");

【问题讨论】:

    标签: html knockout.js richtextbox


    【解决方案1】:

    在标记文件中,我没有使用 ckeditor textarea 的 data-bind 属性

                CKEDITOR.replace('Scope1');
                function GetFormatedTextFromDB(){
    this.Scope1 = ko.observable($('#Scope1').val("<b>Murugesa Pandian test</b>"));
    };
    ko.applyBindings(new GetFormatedTextFromDB());
    

    //将检索到的变量传递给 val 函数 Output from script

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-19
      • 1970-01-01
      • 2015-08-15
      • 2014-07-08
      • 2014-02-21
      • 1970-01-01
      • 1970-01-01
      • 2017-06-19
      相关资源
      最近更新 更多