Hi guys,
while migrating from FCKeditor 2.6.5, I transform my customized dialogs into iframe dialogs.
These dialogs post some changes to the editor when pressing the "ok" button.
I have a serious problem figuring out how to obtain the "ok button was pressed" event in my iframe JavaScript. Has anyone faced this problem and figured out a solution?
Btw: is it possible to activate/deactivate the "ok" or "cancel" button from inside the iframe dialog?
Cheers, zahni
while migrating from FCKeditor 2.6.5, I transform my customized dialogs into iframe dialogs.
These dialogs post some changes to the editor when pressing the "ok" button.
I have a serious problem figuring out how to obtain the "ok button was pressed" event in my iframe JavaScript. Has anyone faced this problem and figured out a solution?
Btw: is it possible to activate/deactivate the "ok" or "cancel" button from inside the iframe dialog?
Cheers, zahni

Re: iframe dialog: how to get the "ok button pressed"
(function() { CKEDITOR.plugins.add('youtube', { requires: ['iframedialog'], init: function(a) { CKEDITOR.dialog.addIframe('youtube_dialog', 'Insert YouTube Movie...', this.path + 'dialogs/youtube.html', 550, 200, function() { /*oniframeload*/ }); a.addCommand('youtube', { exec: function(e) { e.openDialog('youtube_dialog'); } }); a.ui.addButton('youtube', { label: 'Insert YouTube Movie...', command: 'youtube', icon: this.path + 'images/icon.gif' }); } }); })();This displays the youtube.html file successfully in the dialog window but i need to handle the click event of the OK button to insert some html into the page. I've been looking for a solution for a while but so far have found nothing. This seems surprising considering how easy it would make upgrading fckeditor plugins if there was a solution to this.
Re: iframe dialog: how to get the "ok button pressed"
seems that I have found an ugly workaround. Paste the following JS into the script code of your iframe. It would be nice if one of the developers could have a look at this and maybe provide a more easy solution...
/* Initialize important CKEditor variables from opening editor. */ var CKEDITOR = window.parent.CKEDITOR; var oEditor = CKEDITOR.instances.editorName; var okListener = function(ev) { alert("OK!"); // remove the listeners to avoid any JS exceptions CKEDITOR.dialog.getCurrent().removeListener("ok", okListener); CKEDITOR.dialog.getCurrent().removeListener("cancel", cancelListener); }; var cancelListener = function(ev) { alert("CANCEL!"); // remove the listeners to avoid any JS exceptions CKEDITOR.dialog.getCurrent().removeListener("ok", okListener); CKEDITOR.dialog.getCurrent().removeListener("cancel", cancelListener); }; CKEDITOR.event.implementOn(CKEDITOR.dialog.getCurrent()); CKEDITOR.dialog.getCurrent().on("ok", okListener); CKEDITOR.dialog.getCurrent().on("cancel", cancelListener);Re: iframe dialog: how to get the "ok button pressed"
Edit: Here's how it can be done. Simply place the following in the ok event:
this._.editor.insertHtml('<p>Text Here</p>');My final point i'd like to make is that the support on this forum is terrible. I know they all want us to pay for the support but this is a new product and there's little to no documentation so it seems like a con to me. With FCKEditor atleast they built up a community and a knowledge base first.
Re: iframe dialog: how to get the "ok button pressed"
var dialogDefiniton = { title : 'custom buttons dialog', onOk : function() { //Notify your iframe scripts here... } //... };Re: iframe dialog: how to get the "ok button pressed"
Hi cheers but where do you pass this variable in. The iframedialog works slightly different from the standard dialog. Appreciate your help once more. Thanks
Re: iframe dialog: how to get the "ok button pressed"
Sorry for not making this clear in previous post, I'm putting a whole plugin example based on your version, I hope this could help:
/* * @example An iframe-based dialog with custom button handling logics. */ ( function() { CKEDITOR.plugins.add( 'youtube', { requires: [ 'iframedialog' ], init: function( editor ) { var me = this; CKEDITOR.dialog.add( 'youTubeDialog', function () { return { title : 'YouTube Dialog', minWidth : 550, minHeight : 200, contents : [ { id : 'iframe', label : 'Insert YouTube Movie...', expand : true, elements : [ { type : 'iframe', src : me.path + 'dialogs/youtube.html', width : '100%', height : '100%', onContentLoad : function() { // Iframe is loaded... } } ] } ], onOk : function() { // Notify your iframe scripts here... } }; } ); editor.addCommand( 'youtube', new CKEDITOR.dialogCommand( 'youTubeDialog' ) ); editor.ui.addButton( 'youtube', { label: 'Insert YouTube Movie...', command: 'youtube', icon: this.path + 'images/icon.gif' } ); } } ); } )();Re: iframe dialog: how to get the "ok button pressed"
onOk: function() { editor.insertHtml('<cke:youtube url="' + window.frames[0].document.getelementById('url').value + '">YouTube Video Place Marker</cke:youtube>'); }But this did not work. Appreciate your help again. Thanks
Re: iframe dialog: how to get the "ok button pressed"
onContentLoad : function() { var iframe = document.getElementById( this._.frameId ), iframeWindow = iframe.contentWindow; }Re: iframe dialog: how to get the "ok button pressed"
onContentLoad: function(){ // iframe is loaded var iframe = document.getElementById( this._.frameId ), iframeWindow = iframe.contentWindow; }onOk: function(){ editor.insertHtml(iframeWindow.getElementById('test').value); }Re: iframe dialog: how to get the "ok button pressed"
var iframeWindow = null; CKEDITOR.plugins.add('myPlugin',{ requires: ['iframedialog'], .......onContentLoad : function() { var iframe = document.getElementById( this._.frameId ); iframeWindow = iframe.contentWindow; }onOk: function(){ this._.editor.insertHtml(iframeWindow.getElementById('test').value); }Re: iframe dialog: how to get the "ok button pressed"