1
我正在創建一個博客,我想更新一條評論, 我想將評論的當前數據傳遞給使用TINYMCE所見即所得編輯器的textarea。將數據傳遞到使用TINYMCE所見即所得模式的textarea內所見即所得
問題是如果我使用tinymce作爲textarea,當前數據不會顯示在textarea上。
這裏是我如何做到這一點
這將觸發模式按鈕:
<button type="button" class="btn btn-success btn-xs" data-toggle="modal" data-target="#myModal" data-id="{{ $comment->id }}" data-comment=" {{ $comment->comment }}"><i class="fa fa-pencil"></i></button>
這是模態
<!--UPDATE COMMENT Modal -->
<div class="modal fade modal-md" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content modal-success">
{{ Form::open(['route' => ['comments.update'], 'method' => 'PUT']) }}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h5 class="modal-title"><b>Update Comment </b></h5>
</div>
<div class="modal-body">
<div id="comment-form" class="">
<div class="row">
<div class="col-md-12">
{!! Form::hidden('id', '', ['id' => 'comment-id']) !!}
{{ Form::textarea('comment', '', ['id'=>'comment-comment','class' => 'form-control', 'rows' => '3']) }}
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success"><b>Update</b></button>
<button type="button" class="btn btn-default" data-dismiss="modal"> <b>Cancel</b></button>
</div>
{{ Form::close() }}
</div>
</div>
</div>
這裏是我的JS:
<script type="text/javascript" charset="utf-8">
tinymce.init({
selector: 'textarea',
menubar: false,
toolbar: false,
statusbar: false,
height: 10
});
<!--UPDATE COMMENT MODAL-->
$(function() {
$('#myModal').on("show.bs.modal", function (e) {
$("#comment-comment").val($(e.relatedTarget).data('comment'));
$("#comment-id").val($(e.relatedTarget).data('id'));
});
});
// Prevent bootstrap dialog from blocking focusin
$(document).on('focusin', function(e) {
if ($(e.target).closest(".mce-window").length) {
e.stopImmediatePropagation();
}
});
$('#open').click(function() {
$("#dialog").dialog({
width: 800,
modal: true
});
});
</script>
是它可以,但問題是,它是模態,我想返回到使用文本編輯器的文本區域當前註釋的價值,問題是隻有一種形式可以被很多評論使用,當前的評論值只需點擊編輯按鈕即可發送到表單 –