你如何设置TinyMCE textarea元素的焦点? [英] How do you set the focus of a TinyMCE textarea element?

查看:188
本文介绍了你如何设置TinyMCE textarea元素的焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上使用TinyMCE作为textarea,但是在其他元素的Tab键顺序中不起作用。

我可以使用以下代码捕获当我标签的第一个元素:

  $('#title')。live('keypress', (e){
if(e.keyCode == 9){
alert('tabbed out');
}
});

如何将焦点设置为TinyMCE编辑器?


 解决方案

tinymce.execCommand( 'mceFocus',假, 'id_of_textarea');

对于我的目的,id_of_texterea是description,即

 < textarea id =description...>< / textarea> 

在我的textarea之前的表单元素中,我添加了上面的execCommand元素的onblur动作。


I'm using TinyMCE for a textarea on a page but it doesn't play nice in the tabbing order of the other elements.

I can use the following code to capture when I tab out of the first element:

$('#title').live('keypress', function (e) {
   if(e.keyCode == 9) {
       alert('tabbed out');
   }
});

How can I set the focus to a TinyMCE editor?

解决方案

Finally found an answer... use the command:

tinymce.execCommand('mceFocus',false,'id_of_textarea');

For my purposes, 'id_of_texterea' was "description", ie

<textarea id="description" ... ></textarea>

In the form element that preceded my textarea, I added the execCommand above to the element's "onblur" action.

这篇关于你如何设置TinyMCE textarea元素的焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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