Hi, I'm trying to interact with a text box in the Link dialog (get the value and set the value). Started with what's already there but it's not quite working...
Any ideas will be helpful as I'm sure I'm almost there!
R
CKEDITOR.dialog.add('link', function (a)
{
var b = function ()
{
var s = this.getDialog(),
z = s.getContentElement('info', 'txtUrl');
z.setValue('asdasd');
});
});Any ideas will be helpful as I'm sure I'm almost there!
R

Re: Text box in link dialog
Re: Text box in link dialog
The ID numbers do change at runtime but CKEditor getContentElement is supposed to get around that - just don't quite know how to use it yet!
Thanks, R
Re: Text box in link dialog
Re: Text box in link dialog
Re: Text box in link dialog
Then your code should still not look like what you posted...since that's runtime code. (Not that it matters a ton, but just trying to make sure you are actually making changes in the right place). I have no idea what you're actually trying to do, but it seems like most of these changes should be in the dialog not in the plugin, but again, not sure what you're doing.
As it stands, that code should work. Have you step debuged with firebug? Do you get an error of some type?
Re: Text box in link dialog
Well, I have a button that needs to change the value of the URL field, so I need to be able to access it. I can do "text_input_32.value='asdasd'" which works absolutely fine - but CKEditor changes the ID number depending on various things so I need a sort of 'absolute' reference to that text box.
The text box is called 'txtURL' when it's created so getContentElement should be able to reference that name.
Happy to execute something similar at runtime but then "this" would have to be referenced as well - and again, I'm not sure what the correct API call is...
Any ideas?
Re: Text box in link dialog
var dialog = this.getDialog(), urlfield = dialog.getContentElement('info', 'txtUrl'); urlfield.setValue(this.getDialog());You'll have to double check that. I always get the scope of getDialog mixed up. The button is in CKEditor or no?
If it's not, then the problem is that the scope of 'this' is probably wrong. And you have to do some hunting to make sure you are in the right window and can access the CKEDITOR.editor element. Let me know if you still have problems (And how you're putting the button in and such= and I can try to find a better example
Re: Text box in link dialog
I decided to play around with some runtime code that I knew already worked - this is the code that alters the link dialog at runtime.
if ( dialogName == 'link' ) { // Get a reference to the Link Info tab. var infoTab = dialogDefinition.getContents( 'info' ); // Remove the Target tab from the Link dialog. dialogDefinition.removeContents( 'advanced' ); }So I added:
urlfield = dialogDefinition.getContentElement('info', 'txtUrl'); urlfield.setValue('Some new text');and also tried:
urlfield = infoTab.getContentElement('info', 'txtUrl'); urlfield.setValue('Some new text');But both gave an error: dialogDefinition.getContentElement / infoTab.getContentElement is not a function.
I feel like this must be a function that's used quite commonly and it's documented but just makes no sense so quite frustrating! Any more ideas will really help!
Re: Text box in link dialog
For instance I have in one of my plugins:
var generatePicture = function(dialog, mode) { ..... } //In my onOk function, I can then use: generatePicture(this, 'for realz'); //Because in the onOk, this is the dialogSimilarly, you just have to alter it depending on where your coming from. Remember you can always use this.getDialog if you are only in the editor scope. I.E. From one of my added buttons:
Re: Text box in link dialog
http://redhive.co.uk/clientspace/cktest/index.html
http://redhive.co.uk/clientspace/cktest/cktest.rar
Re: Text box in link dialog
var dialog = CKEDITOR.dialog.getCurrent(); dialog.setValueof('info','txtUrl',"http://google.com"); return false;