【问题标题】:Bootstrap and wysihtml5 updating textareaBootstrap 和 wysihtml5 更新 textarea
【发布时间】:2013-05-14 13:57:37
【问题描述】:

我正在使用:

  • wysihtml5
  • bootstrap-wysihtml5.js

我有一个名为 Booking_CancellationComments_CancellationPolicy 的文本区域,并正在使用此代码将其设为 wysihtml5 文本区域:

$('#Booking_CancellationComments_CancellationPolicy').wysihtml5(options);

我正在尝试稍后使用:

$('#Booking_CancellationComments_CancellationPolicy').val(data.Booking.CancellationComments.CancellationPolicy);

但是文本区域没有更新。我在 Stack Overflow 上查看了很多答案,并没有展示如何使用我使用过的初始化方法来更新 textarea。

任何帮助表示赞赏。

【问题讨论】:

    标签: twitter-bootstrap textarea wysihtml5


    【解决方案1】:

    试试这个:

    $('#Booking_CancellationComments_CancellationPolicy').data("wysihtml5").editor.setValue(data.Booking.CancellationComments.CancellationPolicy);

    【讨论】:

    • 如果 $("#Description").data('wysihtml5').editor = undefined 会有什么问题。谢谢。
    【解决方案2】:

    //对于编辑器=未定义。构造函数没有初始化编辑器

    var wysihtml5 =   $("#Booking_CancellationComments_CancellationPolicy").wysihtml5() ;
    wysihtml5 = wysihtml5.data("wysihtml5");
    wysihtml5.createEditor({}); "create the editor 
    

    ....

    wysihtml5.editor.setValue("some html"); 
    

    【讨论】:

      【解决方案3】:

      我在编辑器 == 'undefined' 上遇到了同样的问题,并通过以下方式解决了它:

      $('.wysihtml5-sandbox').contents().find('body').html('<b>New text</a>');
      

      我知道,这不是最好的解决方案,但只有这对我有用。如果您有更好的解决方案,请告诉我。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-17
        • 1970-01-01
        • 2013-09-07
        相关资源
        最近更新 更多