CKEditor dialogs: referencing input fields by ID

天大地大妈咪最大 提交于 2019-12-31 03:55:09

问题


Each input field in the CKEditor dialogs are renamed with a unique number, but the number changes depending on what options are visible.

I need to reference 'txtUrl' which has an id something like #35_textInput.

So far I have discovered that something like this should work:

alert(CKEDITOR.instances.myElement.document.$.body.getId('txtUrl'));

But it doesn't. Please help.


回答1:


@Rio, your solution was really close! This was the final solution:

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



回答2:


var dialog = this.getDialog();
var elem = dialog.getContentElement('info','txtUrl');



回答3:


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.

SetValueOf still doesn't provide the id, which you may need if you want to do more than fill a text field with a certain text.



来源:https://stackoverflow.com/questions/2777286/ckeditor-dialogs-referencing-input-fields-by-id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!