按键上的Tinymce我正在尝试显示内容的预览 [英] Tinymce on keypress I am try to display the preview of the content

查看:334
本文介绍了按键上的Tinymce我正在尝试显示内容的预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码

I am trying below code

 $('textarea.tinymce').keypress(function(){
      dealDescription = $('textarea.tinymce').tinymce().execCommand('mcePreview');
      $("#deal_preview div").text(dealDescription);
 });

但是我不使用jquery tinymce编辑器,假设我使用jquery tinymce和其他jquery UI组件无法正常工作,所以我直接使用了tinymce组件.

But I am not using jquery tinymce editor suppose I use jquery tinymce and other jquery UI component not working properly so I am directly using the tinymce component.

现在,我需要在每次按键时在预览框中显示内容预览.

Now I need to show content preview in preview box for each key press.

推荐答案

我在tinymce 4.x中使用它

Im using this in tinymce 4.x

tinymce.init({
    selector: "#tinymce-textarea",
    setup : function(ed) {
        ed.on("change", function(e){
            $('#tinymce-livepreview').html(tinymce.activeEditor.getContent());
        });
        ed.on("keyup", function(){
            $('#tinymce-livepreview').html(tinymce.activeEditor.getContent());
        });
   }
});

说明:

on("change")用于检测鼠标事件的变化.它也能够检测键盘事件,但是只能在失去焦点后才能检测到(不是实时的).

on("change") is for detect changes on mouse event if u click toolbar icon or selection from the menu. It also able to detect the keyboard event but only after lost focus (not real time).

on("keyup")用于检测实时键盘事件的变化

on("keyup") is for detect changes on real time keyboard event

这篇关于按键上的Tinymce我正在尝试显示内容的预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆