按tab键时如何选择tinyMCE文本区域?

发布于 2024-10-31 00:43:12 字数 477 浏览 1 评论 0原文

你好 我得到了类似于该代码

<form method="post" action="/" name="form" autocomplete="off">
<input type="text" name="title" />
<textarea name="body"></textarea>
<input type="text" name="tags" />
<input type="submit" name="submit" value="Send" />
</form>

“textarea”是tinyMCE...当我尝试通过输入和textarea项目移动选择时出现问题。 加载页面时,它聚焦 input[name=text] 但当我按 Tab 键时,它选择 input[name=tags] 而不是 textarea[name=body] (这是下一个) 你能帮我解决这个问题吗?

Hello
I got similar to that code

<form method="post" action="/" name="form" autocomplete="off">
<input type="text" name="title" />
<textarea name="body"></textarea>
<input type="text" name="tags" />
<input type="submit" name="submit" value="Send" />
</form>

Where the "textarea" is tinyMCE... problem comes when I try to move selection through input and textarea items.
When the page is loaded it focus input[name=text] but when I press Tab key it select input[name=tags] instead textarea[name=body] (which is next)
Can you assist me with that issue ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

星光不落少年眉 2024-11-07 00:43:12

这对于传统的选项卡索引来说是不可能的,因为 TinyMCE 实际上隐藏了

$('#prev-input').blur(function(){
    tinyMCE.get('textarea').focus();
});

然后,一旦用户离开前一个输入焦点,就会跳转到 TinyMCE编辑器中,您也可以添加一个 Blur() 方法来到达下一个元素。

This is impossible with conventional tab indexes as TinyMCE actually hides the <textarea> and creates an <iframe> with the editor in it. You could make a work around by forcing focus on the editor in the blur event of the previous element in javascript, here is ajQuery snipped of the top of my head:

$('#prev-input').blur(function(){
    tinyMCE.get('textarea').focus();
});

Then as soon as the user leaves the previous input focus would jump to the TinyMCE editor, you could possibly add a blur() method as well to got to the next element.

一枫情书 2024-11-07 00:43:12

我通过向插件添加 'tabfocus' 来解决此问题,然后添加 tabfocus_elements : ":prev,:next"

http:// tinymce.moxiecode.com/wiki.php/Plugin:tabfocus

http://tinymce.moxiecode.com/wiki .php/tabfocus_elements

I resolved this with adding 'tabfocus' to plugins and then add tabfocus_elements : ":prev,:next"

http://tinymce.moxiecode.com/wiki.php/Plugin:tabfocus

http://tinymce.moxiecode.com/wiki.php/tabfocus_elements

成熟稳重的好男人 2024-11-07 00:43:12

我需要来自页面上另一个元素的自定义选项卡顺序。我在 IE11 中用于解决此问题的代码是

var button = $('#btn-id');
button.on('keydown', function (e) {
    if ((e.which === 9 && !e.shiftKey)) {
        e.preventDefault();
        $(tinyMCE.get()[0].contentWindow).focus();
    }
});

请注意,上述代码仅在页面上只有一个编辑器时才有效。否则,您将必须循环遍历 tinyMCE.get() 返回的数组,以找到要设置焦点的正确编辑器。

I needed a custom tabbing order from another element on the page. The code I used to resolve this in IE11 was

var button = $('#btn-id');
button.on('keydown', function (e) {
    if ((e.which === 9 && !e.shiftKey)) {
        e.preventDefault();
        $(tinyMCE.get()[0].contentWindow).focus();
    }
});

Be aware that the above code will only work if you've only got one editor on the page. Otherwise you'll have to cycle through the array returned by tinyMCE.get() to find the correct editor to set focus to.

娜些时光,永不杰束 2024-11-07 00:43:12

我发现 focus 事件被触发,但在元素(容器)中聚焦并不总是有效。

就我而言,我从编辑器 1 - 4 进行 Tab 键切换,当我按 Shift+Tab 键时,我失去了对实例的关注。

为了解决这个问题,我将以下内容添加到tinyMCE的设置事件中

setup: function(editor) {
  editor.on("focus", function(e) {
    e.target.editorContainer.scrollIntoView();
  });
}

I found out that the focus event is being triggered but focussing in the element (container) didn't work all the time.

In my case I tabbed from editor 1 - 4 and when I shift+tab I lost focus on the instance.

To fix this I added the following to the setup event of tinyMCE

setup: function(editor) {
  editor.on("focus", function(e) {
    e.target.editorContainer.scrollIntoView();
  });
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文