开发者

Referencing text input fields in CKEditor dialogs

开发者 https://www.devze.com 2022-12-30 22:57 出处:网络
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 l

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(开发者_StackOverflow社区'info','txtUrl');

// and then:

myfield.value = 'myvalue';

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


This was the final solution:

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


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.


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.


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';


get

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

and set

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

精彩评论

暂无评论...
验证码 换一张
取 消