Php 刷新div时,ckeditor消失
我有两个页面,分别是openclosediv.php和content.php。在openclosediv.php页面中,我有一个记录列表和一个按钮(show/hide div按钮),该按钮将content.php带到openclosediv.php中的。在content.php页面中,每当我点击按钮时,我都会有一个ckeditor,如上所述,第一次出现ckeditor时,在第一次按下按钮后,ckeditor不会出现 下面是在openclosediv.php中显示/隐藏div的代码:Php 刷新div时,ckeditor消失,php,javascript,jquery,html,ckeditor,Php,Javascript,Jquery,Html,Ckeditor,我有两个页面,分别是openclosediv.php和content.php。在openclosediv.php页面中,我有一个记录列表和一个按钮(show/hide div按钮),该按钮将content.php带到openclosediv.php中的。在content.php页面中,每当我点击按钮时,我都会有一个ckeditor,如上所述,第一次出现ckeditor时,在第一次按下按钮后,ckeditor不会出现 下面是在openclosediv.php中显示/隐藏div的代码: fu
function ShowHideDiv(divid)
{
var block=document.getElementById(divid).style.display;
if(block=="none")
{
document.getElementById(divid).style.display="block";
}
else
{
document.getElementById(divid).style.display="none";
}
var data="divid="+divid;
jQuery('#'+divid).showLoading();
$.ajax({
type: "POST",
url: "content.php",
data: data,
error: function(){
alert('Error while loading!');
},
success: function(data){
jQuery('#'+divid).hideLoading();
$('#'+divid).html(data);
}
});
}
下面是我如何在content.php中创建ckeditor:
$ckeditor = new CKEditor();
$ckeditor->basePath = 'ckeditor/' ;
CKFinder::SetupCKEditor( $ckeditor, 'ckfinder/' ) ;
$config['height'] = '300';
$config['width'] = '700';
$initialValue = "";
$ckeditor->editor("somename", $initialValue, $config);
提前谢谢 由于您使用的是jQuery,因此可以使用
.toggle()
方法,而不是手动显示和隐藏:
function ShowHideDiv(divid)
{
$('#' + divid).toggle();
// Do ajax
}
.toggle()
代码应取代此部件:
var block=document.getElementById(divid).style.display;
if(block=="none")
{
document.getElementById(divid).style.display="block";
}
else
{
document.getElementById(divid).style.display="none";
}
谢谢你的回复。但我正在content.php页面中进行一些数据库处理。如果我编写.toggle(),它还会工作吗;我应该把它放在我放$('#'+divid.html(数据)的那一行吗;见我的编辑上面。此javascript是在客户端执行的,因此您在服务器上执行的操作会在这之前发生;然而,它没有再次起作用。