gpt4 book ai didi

javascript - 为什么以及如何为ckeditor解决 'Uncaught TypeError: Cannot read property ' setData' of undefined'

转载 作者:行者123 更新时间:2023-11-30 00:29:02 25 4
gpt4 key购买 nike

我在 Bootstrap 模式中使用 ckeditor。 ckeditor 中的数据应该在 ajax 调用后动态加载。我无法在 ckeditor 中加载数据。代码:

<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel">Thank you Message</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="recipient-name" class="control-label">Recipient:</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="recipient-name" class="control-label">Subject:</label>
<input type="text" class="form-control" id="subject">
</div>
<div class="form-group">
<label for="message-text" class="control-label">Message:</label>
<?php $ckeditor->editor('message', '', array('id'=>'editor1')); ?>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Send message</button>
</div>
</div>
</div>
</div>

脚本

$(document).on('click', '#sendemail', function(){
var target = $('#hidden_send_email_url').val();
var id = $(this).find('#hidden_id').val();
$.ajax({
url : target,
data : {id : id},
type : 'POST',
dataType: "json",
success : function(data){
var modal = $('#exampleModal').modal('show');
modal.find('.modal-body input#recipient-name').val(data.to)
modal.find('.modal-body input#subject').val(data.subject)
CKEDITOR.instances.editor1.setData(data.message)


},
error : function(){
alert('Error occured');
}
})
})

错误是:未捕获类型错误:无法读取未定义的属性“setData”如何解决这个问题?欢迎任何帮助/建议。谢谢。

最佳答案

我刚刚通过从 textarea 中删除 id 属性解决了这个问题

关于javascript - 为什么以及如何为ckeditor解决 'Uncaught TypeError: Cannot read property ' setData' of undefined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30294356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com