jQuery 可视化编辑器 (TinyMCE) 上的 keyup()
jQuery keyup() on Visual editor (TinyMCE)
Wordpress 正在使用 TinyMCE 编辑器作为可视化编辑器。
我想在这个编辑器中打字。我有这个代码:
tinyMCE.activeEditor.onKeyUp.add(function(ed, e) {
console.debug(
tinyMCE.activeEditor.getContent({format : 'raw'})
)
});
这是有效的,但如果在加载页面时编辑器未处于活动状态,我会收到错误消息 "Deprecated TinyMCE API call: .onKeyPress.add(..)"
在此编辑器中钩住输入的最佳代码是什么
要向元素添加事件侦听器,您需要先 select 正确地添加它。
例如:
<textarea id="visual_editor_selector"></textarea>
在JQuery中,id属性用#号调用,如:
$('#visual_editor_selector')
如果您使用的是tinymce的V4,事件的绑定自V3以来已经发生了变化。绑定事件的新方法是
tinyMCE.activeEditor.on('keyup', function(ed, e) {
console.debug(
tinyMCE.activeEditor.getContent({format : 'raw'});
);
});
看到这个DEMO
Wordpress 正在使用 TinyMCE 编辑器作为可视化编辑器。
我想在这个编辑器中打字。我有这个代码:
tinyMCE.activeEditor.onKeyUp.add(function(ed, e) {
console.debug(
tinyMCE.activeEditor.getContent({format : 'raw'})
)
});
这是有效的,但如果在加载页面时编辑器未处于活动状态,我会收到错误消息 "Deprecated TinyMCE API call: .onKeyPress.add(..)"
在此编辑器中钩住输入的最佳代码是什么
要向元素添加事件侦听器,您需要先 select 正确地添加它。
例如:
<textarea id="visual_editor_selector"></textarea>
在JQuery中,id属性用#号调用,如:
$('#visual_editor_selector')
如果您使用的是tinymce的V4,事件的绑定自V3以来已经发生了变化。绑定事件的新方法是
tinyMCE.activeEditor.on('keyup', function(ed, e) {
console.debug(
tinyMCE.activeEditor.getContent({format : 'raw'});
);
});
看到这个DEMO