Hey All,
I have the window opening perfectly, but how would I enable the closing of the window calling the parent window as well?
Telerik.Web.UI.Editor.CommandList["InsertTopsImage"] = function(commandName, editor, args) {
var myCallbackFunction = function(sender, args) {
editor.pasteHtml("<img src=\"/image.ashx?id=" + args + "\" />");
}
editor.showExternalDialog(
'/securearea/imagelist',
null,
700,
600,
myCallbackFunction,
null,
'Insert TOPS Image',
true,
Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
false,
true);
}
I would also like the mycallbackFunction or some other function to be called when the close button is clicked in the status bar.
Thanks.
Tim
I have the window opening perfectly, but how would I enable the closing of the window calling the parent window as well?
Telerik.Web.UI.Editor.CommandList["InsertTopsImage"] = function(commandName, editor, args) {
var myCallbackFunction = function(sender, args) {
editor.pasteHtml("<img src=\"/image.ashx?id=" + args + "\" />");
}
editor.showExternalDialog(
'/securearea/imagelist',
null,
700,
600,
myCallbackFunction,
null,
'Insert TOPS Image',
true,
Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
false,
true);
}
I would also like the mycallbackFunction or some other function to be called when the close button is clicked in the status bar.
Thanks.
Tim
5 Answers, 1 is accepted
0
Hi Tim,
Please, find attached a sample project, which demonstrates how to call the callback function of RadEditor when closing the custom RadWindow dialog via the X close button.
Kind regards,
Rumen
the Telerik team
Please, find attached a sample project, which demonstrates how to call the callback function of RadEditor when closing the custom RadWindow dialog via the X close button.
Kind regards,
Rumen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Tim Leung
Top achievements
Rank 1
answered on 19 Aug 2010, 07:06 PM
Thanks for the demo, but I am having the following issue:
too much recursion
http://localhost:8123/ScriptResource.axd?d=nIL1yNzQ_LKysPrpG8pvoSt9gVZIu-Y9YACf0Os6ZiF3kfeuD8_Mxu4JbP0-xl0SnyOolw6z1oFnkIu9NgxBbkOhPyKKf-nJtAvhkhoW7_U1&t=ffffffffec2d9970
Line 195
function initDialog()
{
alert("init!");
var oWindow = getRadWindow();
alert(windowBeforeCloseHandler);
oWindow.add_beforeClose(windowBeforeCloseHandler);
}
if (window.attachEvent) {
window.attachEvent("onload", initDialog);
}
else if (window.addEventListener) {
window.addEventListener("load", initDialog, false);
}
function getRadWindow() {
if (window.radWindow) {
return window.radWindow;
}
if (window.frameElement && window.frameElement.radWindow) {
return window.frameElement.radWindow;
}
return null;
}
function radEditorInsert(workLink) {
getRadWindow().close(workLink);
}
function windowBeforeCloseHandler(oWindow, args) {
//args.set_cancel(true);
//oWindow.remove_beforeClose(windowBeforeCloseHandler);
//var closeArgument = {};
//oWindow.close(closeArgument);
//alert("test");
}
alert Init! runs but just when that function is completed, that error is thrown.
too much recursion
http://localhost:8123/ScriptResource.axd?d=nIL1yNzQ_LKysPrpG8pvoSt9gVZIu-Y9YACf0Os6ZiF3kfeuD8_Mxu4JbP0-xl0SnyOolw6z1oFnkIu9NgxBbkOhPyKKf-nJtAvhkhoW7_U1&t=ffffffffec2d9970
Line 195
function initDialog()
{
alert("init!");
var oWindow = getRadWindow();
alert(windowBeforeCloseHandler);
oWindow.add_beforeClose(windowBeforeCloseHandler);
}
if (window.attachEvent) {
window.attachEvent("onload", initDialog);
}
else if (window.addEventListener) {
window.addEventListener("load", initDialog, false);
}
function getRadWindow() {
if (window.radWindow) {
return window.radWindow;
}
if (window.frameElement && window.frameElement.radWindow) {
return window.frameElement.radWindow;
}
return null;
}
function radEditorInsert(workLink) {
getRadWindow().close(workLink);
}
function windowBeforeCloseHandler(oWindow, args) {
//args.set_cancel(true);
//oWindow.remove_beforeClose(windowBeforeCloseHandler);
//var closeArgument = {};
//oWindow.close(closeArgument);
//alert("test");
}
alert Init! runs but just when that function is completed, that error is thrown.
0
Hello Tim,
You should not comment the code of the windowBeforeCloseHandler function, because exactly it prevents the recursion. It is also important to remove the windowBeforeCloseHandler handler before closing the dialog using the remove_beforeClose method and provide an argument to the oWindow.close function so that the callback function is executed, e.g.
Greetings,
Rumen
the Telerik team
You should not comment the code of the windowBeforeCloseHandler function, because exactly it prevents the recursion. It is also important to remove the windowBeforeCloseHandler handler before closing the dialog using the remove_beforeClose method and provide an argument to the oWindow.close function so that the callback function is executed, e.g.
function windowBeforeCloseHandler(oWindow, args) {
args.set_cancel(true);
oWindow.remove_beforeClose(windowBeforeCloseHandler);
var closeArgument = {};
closeArgument.image = "Emoticons/smil1.GIF"
oWindow.close(closeArgument);
}
function insertEmoticon(url) //fires when the Insert Link button is clicked
{
var oWindow = getRadWindow();
oWindow.remove_beforeClose(windowBeforeCloseHandler);
var closeArgument = {};
closeArgument.image = url
getRadWindow().close(closeArgument);
}
Greetings,
Rumen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Tim Leung
Top achievements
Rank 1
answered on 01 Sep 2010, 09:22 PM
I have the following but it doesn't seem to be working as the recursion javascript error is still happening.
function
initDialog()
//called when the dialog is initialized
{
var
oWindow = getRadWindow();
var
clientParameters = getRadWindow().ClientParameters;
oWindow.add_beforeClose(windowBeforeCloseHandler);
}
if
(window.attachEvent) {
window.attachEvent(
"onload"
, initDialog);
}
else
if
(window.addEventListener) {
window.addEventListener(
"load"
, initDialog,
false
);
}
function
getRadWindow() {
if
(window.radWindow) {
return
window.radWindow;
}
if
(window.frameElement && window.frameElement.radWindow) {
return
window.frameElement.radWindow;
}
return
null
;
}
function
radEditorInsert(workLink, type, imgSrc, imgID) {
args = {};
args.workLink = workLink;
args.type = type;
args.imgSrc = imgSrc;
args.AssetId = imgID;
var
oWindow = getRadWindow();
oWindow.remove_beforeClose(windowBeforeCloseHandler);
getRadWindow().close(args);
}
function
windowBeforeCloseHandler(oWindow, args) {
args.set_cancel(
true
);
oWindow.remove_beforeClose(windowBeforeCloseHandler);
var
closeArgument = {};
oWindow.close(closeArgument);
}
0
Hi Tim,
Your example differs from the provided one meant for emoticons. Can you please open a new support ticket and send a fully working project that demonstrates the recursion problem? This will be the fastest way to help you.
Best regards,
Rumen
the Telerik team
Your example differs from the provided one meant for emoticons. Can you please open a new support ticket and send a fully working project that demonstrates the recursion problem? This will be the fastest way to help you.
Best regards,
Rumen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items