在我的项目中,CKEditor 用于富文本界面。问题是:- 我有一个 jquery 弹出框。在显示此弹出框之前,我在获取记录后对服务器进行了 ajax 调用以获取记录,它显示用于编辑记录的编辑界面有一个文本区域,我需要集成 CKEditor。当我集成编辑器时,文本区域已成功更改为编辑器,但未在文本区域内显示文本。我可以看到 textarea 在 firebug 中填充了文本,但编辑器为空白且无法编辑。
这是我的代码
这是主页
<?php $this->load->view('menu'); ?>
<div id="rightContent">
<h3>Events & News</h3>
<div align="right">
<?php echo anchor('eventsandnews/add','ADD NEW',array('class'=>'button')); ?>
</div>
<div class="sukses" style="display:none;">
</div>
<table class="data">
<tr class="data">
<th class="data" width="30">No</th>
<th class="data">Text</th>
<th class="data">Date</th>
<th class="data" width="75">Actions</th>
</tr>
<?php
$i=1;
foreach ($query->result() as $row){ ?>
<tr class="data" id="an<?php echo $row->id; ?>">
<td class="data" width="30"><?php echo $i; ?></td>
<td class="data"><?php echo substr($row->newstxt,0,30); ?></td>
<td class="data"><?php echo $row->ndate; ?></td>
<td class="data" width="75">
<center>
<a href="<?php echo $row->id; ?>" id="edit" class="edit" name="edit"><img src="<?php echo base_url(); ?>mos-css/img/edit.png"></a>
<a href="<?php echo $row->id; ?>" id="delete" class="delete" name="delete"><img src="<?php echo base_url(); ?>mos-css/img/delete.png"></a>
</center> </td>
</tr>
<?php
$i++;
} ?>
</table>
<div id="paging">
<?php echo $paging; ?>
</div>
</div>
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
height: 350,
width: 500,
show: {
effect: "slide",
duration: 500
},
hide: {
effect: "slide",
duration: 500
}
});
$(".edit").click(function(event){
event.preventDefault();
var id = $(this).attr("href");
$.ajax({
url: '<?php echo site_url().'eventsandnews/edit/'; ?>'+id,
success: function(data) {
$("#dialog").html(data);
$( "#dialog" ).dialog( "open" );
debugger;
CKEDITOR.replace( 'update' );
}
});
});
$(".delete").click(function(event){
event.preventDefault();
var v = confirm('Are you sure to delete?');
if(v==true){
var id = $(this).attr("href");
$.ajax({
url: '<?php echo site_url().'eventsandnews/delete/'; ?>'+id,
success: function(data) {
$('.sukses').html('Deleted successfully');
$('#an' +id).remove();
$('.sukses').show('slow');
setTimeout(function() {
$('.sukses').hide('slow');
}, 2500);
}
});
}
});
});
</script>
<div id="dialog" title="Edit">
</div>
这是 Ajax 页面
<script>
$(document).ready(function(){
$( "#eventsandnewsdate" ).datepicker();
$( "#eventsandnewsdate" ).datepicker( "option", "dateFormat", "dd/mm/yy" );
$("#sub").click(function(){
var a = $("#update").val();
if($.trim(a)==''){
$('.gagal').html('Must enter a announcement !');
$('.gagal').show('slow');
}else{
var hiddenid = $('#id').val();
var text = $('#update').val();
$.ajax({
type: "POST",
url: "<?php echo site_url().'announcements/update/'; ?>",
data: { id: hiddenid, announce: text }
}).done(function( msg ) {
if(msg==1){
$( "#dialog" ).dialog( "close" );
setTimeout(function() {
document.location.reload();
}, 600);
}
});
;
}
});
});
</script>
<div class="gagal" style="display:none;">
</div>
<table width="95%">
<tr>
<td><strong>Annoucement</strong></td>
<td><textarea onclick="$('.gagal').hide('slow');" name="update" id="update" ><?php echo $query[0]['atext']; ?>
</textarea></td>
</tr>
<tr>
<td width="125">Date</td><td> </td></tr>
<tr><td></td><td><input type="button" class="button" id="sub" name="sub" value="Submit">
<input type="hidden" name="id" id="id" value="<?php echo $id; ?>">
</td></tr>
</table>
谁能帮帮我吗?