在tinymce文本区域中输入时,如何将字符附加到文本框,直到按ENTER键?

发布于 2024-11-30 03:23:49 字数 73 浏览 3 评论 0原文

我有一个简单的文本框和一个“tinymce-d”的文本区域。 我想将在tinymce中输入的字符附加到文本框内容,直到按ENTER键

I have a simple textbox and a textarea which is "tinymce-d".
I'd like to append characters that I type into tinymce to textbox contents until I press ENTER

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

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

发布评论

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

评论(3

温柔戏命师 2024-12-07 03:23:49

ShankarSangolis 方法的修正。 Tinymce 可以针对文本区域进行初始化,但它是一个内容可编辑的 iframe,而文本区域(或其他初始化 html 元素)将被隐藏。这是正确的做法。您需要在 tinymce init 上或之后调用此代码,然后用户才能键入。

// the editorid equals the textarea id!
var editor = tinymce.get(editor_id) || tinymce.editors[0]; // use first tinymce editor if no editorid was provided
$(editor.getBody()).keyup(function(e){
   if(e.which != 13){
      $("textbox").val(this.value);
   }
});

Correction of ShankarSangolis approch. Tinymce may be initialized for a textarea, but it is a contenteditable iframe while the textarea (or other init html element) becomes hidden. This is the correct way to do it. You need to call this code eigther on tinymce init or afterwards befor a user can type.

// the editorid equals the textarea id!
var editor = tinymce.get(editor_id) || tinymce.editors[0]; // use first tinymce editor if no editorid was provided
$(editor.getBody()).keyup(function(e){
   if(e.which != 13){
      $("textbox").val(this.value);
   }
});
方觉久 2024-12-07 03:23:49

试试这个。

$("textarea").keyup(function(e){
   if(e.which != 13){
      $("textbox").val(this.value);
   }
});

Try this.

$("textarea").keyup(function(e){
   if(e.which != 13){
      $("textbox").val(this.value);
   }
});
葬心 2024-12-07 03:23:49

这是我使用 dugin tinymce init 的代码:

setup : function (theEditor) {
    theEditor.onKeyUp.add(
        function (theEditor, event) {
            if(event.keyCode == 13) stop = true;
            if (stop == false) {
            var content = theEditor.getContent();
                $("#subject").val(content);
            }
        }
    );
}

stop 是在 init 之前初始化的全局变量,然后 window.stop 在需要时获取值。

Here's the code I'm using dugin tinymce init:

setup : function (theEditor) {
    theEditor.onKeyUp.add(
        function (theEditor, event) {
            if(event.keyCode == 13) stop = true;
            if (stop == false) {
            var content = theEditor.getContent();
                $("#subject").val(content);
            }
        }
    );
}

stop is a global variable initialized before the init and then window.stop gets value when needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文