This is a migrated thread and some comments may be shown as answers.

[Solved] CallerObj for RadConfirm?

7 Answers 548 Views
Window
This is a migrated thread and some comments may be shown as answers.
rcbarth
Top achievements
Rank 1
rcbarth asked on 07 Mar 2008, 12:44 AM

The radconfirm function has the following function signature according to the documentation:

radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle)

And the callback function that's passed as parameter callBackFn in the above signature has a function signature of:

confirmCallBackFn(arg)

The Arg parameter is described as being True if the user clicks OK and False if the user clicks Cancel (should actually be true and false -- little "T" and little "F", but I digress).

My main question: what happens to callerObj parameter defined in the radconfirm function signature? Shouldn't it be passed into the confirmCallBackFn as a parameter (e.g. the function signature should change to be confirmCallBackFn(arg, callerObj))? This would be very convenient as I could then abstract away the calling of the confirmation dialog somewhere else and pass into my convenience function the function that should run on confirmation. E.g.:

function doConfirm(message, title, functionToCallOnConfirm)  
{  
  radconfirm(message, onConfirmCallback, nullnull, funtionToCallOnConfirm, title);  
};  
 
function onConfirmCallback(arg, callerObj)  
{  
  if (arg)  
    callerObj();  

Then, where I need the confirmation dialog in my client app, I can simply do:

function somethingThatRequiresConfirmation()  
{  
  doConfirm("message""title", doSomething);  
}  
 
function doSomething()  
{  
  // Code to do something  

This is nice because every developer on the team doesn't have to concern themselves with how the confirmation dialog works. They just call the doConfirm function with their text, pass their worker function and they're done.

Secondary, and very minor question: Isn't there a better way than completely overriding the dialog template to change the text on the buttons? The documentation indicates the text is "Yes" and "No," however, in practice (at least with the "WebBlue" skin) the text is actually "OK" and "Cancel" mimicking the undesirable behavior of the default javascript confirm function.

7 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 07 Mar 2008, 04:51 PM
Hi rcbarth,


We are not quite sure if we understand completely your scenario, but generally speaking, callerObj is a JavaScript object which contains information about who called the radconfirm dialog and can be used in some scenarios. For example you can check the following Code Library article: Block the execution thread with radconfirm.

In the code that you posted, you are trying to use callerObj as a function - we are not sure why you want to do this, but we would suggest to put the onConfirmCallback() function inside the doConfirm() one. This way you can have the callerObj in your callback function.

function doConfirm(message, title, functionToCallOnConfirm)         
{   
 
function onConfirmCallback(arg, callerObj)    
{   
   if (arg) functionToCallOnConfirm();   
}  
 
radconfirm(message, onConfirmCallback, nullnull, funtionToCallOnConfirm, title);       
};   
 

As for your last question, I believe the following forum thread will be of help: Localization in Q3?



Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
rcbarth
Top achievements
Rank 1
answered on 07 Mar 2008, 06:10 PM
In your current implementation, unless I'm missing something, the CallerObj parameter is completely useless as it cannot be inspected by the user (the developer, me). IMO, it should be passed to the callback function as a second parameter (in addition to the result of the dialog) so that the callback function gets the data passed to the confirmation dialog in that parameter.

How does one inspect the contents of that parameter in the current implementation? As near as I can tell, there's no way to do so.
0
Georgi Tunev
Telerik team
answered on 10 Mar 2008, 04:53 PM
Hi rcbarth,

I am not quite sure what do you mean by callerObj being completely useless - as noted in my previous reply in the Block the execution thread with radconfirm code library article you can see a working example of its usage.

Also can you please let us know whether you have tried the suggested code and does it fit your requirements? If it doesn't, we will appreciate it if you can send us more details about what exactly you want to achieve and we will do our best to help.



Kind regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
rcbarth
Top achievements
Rank 1
answered on 11 Mar 2008, 12:07 AM
In your example, the CallerObj parameter is used by the overriden radconfirm function itself, NOT OUTSIDE OF IT. It's only of value (and usable) to the radconfirm function. I would think you'd want to pass that out as part of the callback function's function signature so that the code calling the confirmation dialog can pass data to the code handling the confirmation callback.

Yes, your suggestion worked so I no longer care if you "fix" this problem. In my opinion, you can do one of three things:

1. Remove the callerobj parameter. As I mentioned in a previous post, it's useless. If the developer is going to override (re-specify) the radconfirm function anyhow, he can add as many parameters as he wants/needs. There's no need to have a specific parameter that doesn't do anything. Obviously, it causes confusion.

2. Fix the documentation to describe the parameter as "not used."

3. Pass whatever is passed into that parameter back to the handler for the confirmation window since that's what the documentation seems to describe the functionality as anyhow.
0
Georgi Tunev
Telerik team
answered on 11 Mar 2008, 03:29 PM
Hi rcbarth,

We are glad to know that we were able to help. Regarding your comments, indeed you are right - you can pass as many parameters as you need when creating a custom radconfirm().  callerObj however, is used for other purposes and will stay in the radconfirm() implementation due to backwards compatibility.


Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jim
Top achievements
Rank 1
answered on 17 Mar 2008, 09:48 PM
Hello,

I too was in need of the CallerObj that i configured in my radconfirm(..) invocation... You can get at the object this way...

within your callback function...

function

confirmCallBackFn(arg)

{

this.CallerObj

}



you may have already discovered this, but i thought i would share just in case you didnt.

0
Excentive
Top achievements
Rank 1
answered on 18 Mar 2008, 10:14 AM
Thanks a lot Jim ! It works fine. Like rcbrath, I didn't understand why the callerObj property was not use.
Tags
Window
Asked by
rcbarth
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
rcbarth
Top achievements
Rank 1
Jim
Top achievements
Rank 1
Excentive
Top achievements
Rank 1
Share this question
or