1

我在加载()包含ckeditor的页面时遇到问题。问题是当我加载我的页面时,加载后页面不再包含ckeditor。我的代码在这里:

我在加载()包含ckeditor的页面时遇到问题。问题是当我加载我的页面时,加载后页面不再包含ckeditor。我的代码在这里:

    $("#editpost").click(function(){
            $("#postbodycenter").load("editepost.php");
        });


<?php
include 'php/auth.inc';
include 'manage.php';
if(!empty($_POST["title"]) && !empty($_POST["txfpost"]))
{
    connect();
    if(isset($_POST["select_page_name"]))
    {

        $p_name = mysql_real_escape_string($_POST['select_page_name']);
        $query = 'SELECT `id` FROM `pages` WHERE `page_name` ='.'"$p_id"'.'';
        $get_p_id = mysql_query($query) or die(mysql_error());  
        while ($result = mysql_fetch_array($get_p_id))
        {
            $p_id = $result[id];
            $query ="insert into post (page_id,header,category,date,author,body,more) values
                 ($p_id,'$_POST[title]','$_POST[txfcat]','$_POST[date]','admin','$_POST[txfpost]','$_POST[txfmore]')";
            mysql_query($query) or die(mysql_error());

        }   
    }


}
?>
     <!DOCTYPE  html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>new post</title>

<link rel="stylesheet" href="cssadmin.css" type="text/css" />
<script type="text/javascript"  src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
    $(document).ready(function(){

    $("#btnsub").click(function(){
        var cat = $("#txfcat").val();
        var title = $("#title").val(); 
        var editor1 = $("#editor1").val();
        var editor2 = $("#editor").val();
        if(!(cat == "" || title == "" || editor1 =="" || editor2 == "")){
            alert("Fill all fields!");
        }else{
            $('#form1').submit();
            alert("done");
        }

    });
});
</script>
</head>
<body id ="body">
<center>
                  <form id="form1" name="form1" method="post" action="newpost.php">
                        <table id = "tb_post">
                            <tbody>
                                <tr>
                                    <td>cat</td>
                                    <td><input type="text" name="txfcat" id="txfcat" size="130" /></td>
                                </tr>
                                <tr>
                                    <td>title:</td>
                                    <td><input type="text" name="title" id="title" size="130" /></td>
                                </tr>
                                <tr>
                                    <td>refers to :</td>
                                    <td>
                                        <select name="select_page_name">
                                            <option>select the page</option>
                                            <option value="home">home</option>
                                            <?php pages();?>                                        
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td><input type = "hidden" name = "date" value="<?php echo date("H:i:s d-m-Y")?> "/></td>
                                    <td><textarea class="ckeditor" cols="95" id="editor1" name="txfpost" rows="10"></textarea>
                                    </td>                   
                                </tr>
                                <tr>
                                    <td>more</td>
                                        <td><textarea   class="ckeditor" cols="95" id="editor" name="txfmore" rows="10"></textarea>
                                    </td>
                                </tr>                   
                                <tr>
                                        <td></td>   
                                    <td> <button type="submit" name="btnsub" id="btnsub" value="update">send</button> </td>                 
                                </tr>
                            </tbody>
                        </table>
                </form>
</center>
</body>
</html>
4

1 回答 1

2

您的页面不包含加载 CKEditor 的脚本。

只需将以下代码添加到<script>页面中的一个标签中:

$(document).ready(function(){
    CKEDITOR.replace('editor1');
}
于 2012-07-05T20:04:36.093 回答