Twitter bootstrap 引导和所见即所得HTML5更新文本区
我正在使用:Twitter bootstrap 引导和所见即所得HTML5更新文本区,twitter-bootstrap,textarea,wysihtml5,Twitter Bootstrap,Textarea,Wysihtml5,我正在使用: 所见即所得HTML5 bootstrap-wysihtml5.js 我有一个名为Booking\u CancellationComments\u CancellationPolicy的文本区域,我正在使用以下代码使其成为wysihtml5文本区域: $('#Booking_CancellationComments_CancellationPolicy').wysihtml5(options); 我稍后将尝试使用以下方法更新它: $('#Booking_Cancellation
- 所见即所得HTML5
- bootstrap-wysihtml5.js
$('#Booking_CancellationComments_CancellationPolicy').wysihtml5(options);
我稍后将尝试使用以下方法更新它:
$('#Booking_CancellationComments_CancellationPolicy').val(data.Booking.CancellationComments.CancellationPolicy);
但是文本区域没有更新。我看了很多关于堆栈溢出的答案,但没有说明如何使用我使用的初始化方法更新textarea
感谢您的帮助。试试以下方法:
$('#预订_取消评论_取消策略').data(“wysihtml5”).editor.setValue(data.Booking.CancellationComments.CancellationPolicy)代码>//对于编辑器=未定义。构造函数不会初始化编辑器
var wysihtml5 = $("#Booking_CancellationComments_CancellationPolicy").wysihtml5() ;
wysihtml5 = wysihtml5.data("wysihtml5");
wysihtml5.createEditor({}); "create the editor
我在editor==“undefined”中遇到了相同的问题,并通过以下方法解决了此问题:
$('.wysihtml5-sandbox').contents().find('body').html('<b>New text</a>');
$('.wysihtml5沙盒').contents().find('body').html('newtext');
我知道,这不是最好的解决方案,但只有这样对我有效。如果您有更好的解决方案,请告诉我。如果$(“#Description”).data('wysihtml5').editor=未定义,会出现什么问题。谢谢
$('.wysihtml5-sandbox').contents().find('body').html('<b>New text</a>');