我希望将数据从html data- *传递给CK EDITOR,但我不知道要解决它。
我的HTML:
<a
data-content='MY DATA'
data-toggle="modal" data-target="#modal-data">
<button data-toggle="modal" data-target="#modal-data" title="Edit"><i class="fa fa-pencil"></i></button>
</a>
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" id="modal-data" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="block block-themed block-transparent remove-margin-b">
<div class="block-header bg-primary-dark">
<ul class="block-options">
<li>
<button data-dismiss="modal" type="button"><i class="si si-close"></i></button>
</li>
</ul>
<h3 class="block-title">Form Articles</h3>
</div>
<form class="js-validation-bootstrap form-horizontal" method="post" enctype="multipart/form-data" role="form" id="form">
<div class="block-content">
<div class="form-group">
<label class="col-lg-2 col-sm-2 control-label">Content</label>
<div class="col-lg-10">
<textarea class="form-control" id="content" name="content" style="width: 450%; height: 500px;"></textarea>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div
我试过这个jquery,但不起作用,这里是我的jquery:
$('#modal-data').on('show.bs.modal', function (e) {
var div = $(e.relatedTarget);
var modal = $(this)
$('.block-title').text('Edit Articles');
var b = modal.find('#content').val(div.data('content'));
CKEDITOR.instances['content'].getData(b);
});
如果我使用ckeditor,则不会显示该值,但是当我尝试使用textatrea而没有使用ckeditor时,它已经工作了。
答案 0 :(得分:3)
您需要将setData
用于cke
CKEDITOR.instances['content'].setData(b)