我使用AJAX请求从数据库中获取数据。当我将每个数据传递到输入表单时,一切正常,但是当我将数据传输到CKEditor5时,我得到一个错误:每次我关闭和重新打开模态,模态将出现。传递到CKEditor的数据不会更改,但会创建一个新的CKEditor。这是我的代码为模态和AJAX请求
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="detailModal"
aria-hidden="true" id="detailPlaceModal">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title h4" id="detailModal">Detail Place</h5>
<button type="button" class="btn btn-xs btn-icon btn-ghost-secondary" data-dismiss="modal"
aria-label="Close">
<i class="tio-clear tio-lg"></i>
</button>
</div>
<div class="modal-body">
<div id="detailContent">
<div class="form-group">
<label for="describe_place">Mô tả</label>
<textarea id="editCKeditor" class="form-control" name="describe_view_place"></textarea>
</div>
<div class="form-group">
<button data-modal-hide="defaultModal" type="submit" class="btn btn-primary">I
accept</button>
</div>
</div>
</div>
</div>
</div>
</div>
Ajax
function getDetailPlace(event, element) {
event.preventDefault();
var url = $(element).attr('href');
$.ajax({
url: url,
type: 'GET',
success: function(response) {
var detailData = response.vlplace[0];
$('#describe_view_place').val(detailData.describe_place);
ClassicEditor
.create(document.querySelector('#editCKeditor'))
.then(editor => {
var describeValue = detailData.describe_place;
editor.setData(describeValue);
})
.catch(error => {
console.error(error);
});
$('#detailPlaceModal').modal('show');
},
error: function() {
}
});
}
我研究并修复它,但无法帮助
1条答案
按热度按时间olhwl3o21#
AJAX中