在 CKEditor 对话框中引用文本输入字段

发布于 2024-09-01 07:38:21 字数 424 浏览 7 评论 0原文

我已经玩了几个星期了,但没有成功...

在 CKEditor 对话框中,文本输入字段用唯一的数字重命名 - 例如 id: 'txtUrl' 将变成 id='27_textinput' 之类的内容。

我该如何引用这个?

// I feel it should be something like:

var myfield = CKEDITOR.instances.myElement.document.$.body.getId('txtUrl');

// or maybe:

var myfield = CKEDITOR.dialog.getContentElement('info','txtUrl');

// and then:

myfield.value = 'myvalue';

但这些都不起作用。请帮忙!预先感谢,R

I've been playing around with this for a couple of weeks now with no success...

In a CKEditor dialog, text input fields are renamed with a unique number - e.g. id: 'txtUrl' will become something like id='27_textinput'.

How do I reference this?

// I feel it should be something like:

var myfield = CKEDITOR.instances.myElement.document.$.body.getId('txtUrl');

// or maybe:

var myfield = CKEDITOR.dialog.getContentElement('info','txtUrl');

// and then:

myfield.value = 'myvalue';

But these don't work. Please help! Thanks in advance, R

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

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

发布评论

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

评论(5

分開簡單 2024-09-08 07:38:21

这是最终的解决方案:

var dialog = CKEDITOR.dialog.getCurrent();
dialog.setValueOf('info','txtUrl',"http://google.com");
return false;

This was the final solution:

var dialog = CKEDITOR.dialog.getCurrent();
dialog.setValueOf('info','txtUrl',"http://google.com");
return false;
生死何惧 2024-09-08 07:38:21

在我现在使用的元素的 onchange 部分内

dialog = this.getDialog();  
alert(dialog.getContentElement('info', 'grootte').getInputElement().$.id);  

,它给出“cke_117_select”作为结果。 (这是一个选择框)

alert(dialog.getContentElement('info', 'txtUrl').getInputElement().$.id);  

给出“cke_107_textInput”。
我认为这就是您(或此页面的其他访问者)正在寻找的内容。

within an onchange part of an element I now use

dialog = this.getDialog();  
alert(dialog.getContentElement('info', 'grootte').getInputElement().$.id);  

and it gives 'cke_117_select' as a result. (It's a selectbox)

alert(dialog.getContentElement('info', 'txtUrl').getInputElement().$.id);  

gives 'cke_107_textInput'.
I think this is what you (or other visitors to this page) are looking for.

软糖 2024-09-08 07:38:21

您有一个包含 CKEditor 3 的页面和一个弹出对话框。您可以从此对话框中打开另一个弹出窗口,即 JSP 页面。为了给 CKEditor 父窗口对话框中的字段设置值,请执行以下操作:

window.opener.CKEDITOR.dialog.getCurrent().getContentElement('dialogTabId', 'dialogTabFieldId').setValue('yourValue');

这适用于 CKEditor 3。

You have a page containing the CKEditor 3 and a dialog pop up. You open from this dialog, another pop up window, that is a JSP page. In order to set a value to a field in the dialog of CKEditor's parent window, you do the following:

window.opener.CKEDITOR.dialog.getCurrent().getContentElement('dialogTabId', 'dialogTabFieldId').setValue('yourValue');

This applies to CKEditor 3.

花桑 2024-09-08 07:38:21

查看 api 对话框示例:

    // Get a reference to the "Link Info" tab.
    var infoTab = dialogDefinition.getContents( 'info' );

    // Set the default value for the URL field.
    var urlField = infoTab.get( 'url' );
    urlField['default'] = 'www.example.com';

Look at the api dialog sample:

    // Get a reference to the "Link Info" tab.
    var infoTab = dialogDefinition.getContents( 'info' );

    // Set the default value for the URL field.
    var urlField = infoTab.get( 'url' );
    urlField['default'] = 'www.example.com';
新一帅帅 2024-09-08 07:38:21

获取

var ckValue = CKEDITOR.instances['txtUrl'].getData();

和设置

CKEDITOR.instances['txtUrl'].setData(ckValue);

get

var ckValue = CKEDITOR.instances['txtUrl'].getData();

and set

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