3

I'm using the TinyMCE editor in chat and very uncomfortable to send a message by submit-button. I would like to know, how post message use "onkeypress" in TinyMCE ?

I do this so:

<script type="text/javascript">
tinyMCE.init({
...
        setup : function(ed) {
            ed.onKeyPress.add(
                function (ed, evt) {
                    if(evt.shiftKey && evt.keyCode == 13) {
                        AjaxPost();
                        //alert('shift + enter key');
                        return;
            }              
        });
    }
...
</script>



<script type="text/javascript">
function PostAjax()
{
var Message=document.getElementById('Message').value;
    $.ajax({
        type: "POST",
        url: "PostTinyMCE.php?Message="+Message,
        success: function(html)
        {
        $("#General").html(html);
        }
    });
}
</script>

<textarea name="content" id="Message" style="width:100%"></textarea>

but it does not give me the desired effect, functions AjaxPost(); does't start, where is my mistake? Please help me...

4

1 回答 1

0

在函数中使用 alert 语句AjaxPost来检查函数是否AjaxPost();被执行。如果不是,请尝试将您的 js 函数放在 tinymce init 之前。如果是,您需要验证您的 ajax 代码。

于 2012-11-19T09:19:30.213 回答