I am using a context menu and when a user clicks on a certain menuitem I want a confirm dialog to appear asking whether or not it should proceed with the onclick event. If the user wants to proceed, then the onclick event is triggered, if the user does not, then nothing happens and the confirm dialog just closes. I have tried this using the blockConfirm as shown:
I am pretty sure the problem is with the eventArgs variable that I am sending the blockConfirm. I have the blockConfirm working on a different part of my project when triggered from an ImageButton and that call is:
When I try using the variable "event" with the onclientclicking I get an error saying it does not exist. So what do I need to do to make this work with a RadMenuItem?
I read on the forums and could not find any answer, however this has been asked before here: http://www.telerik.com/community/forums/aspnet-ajax/treeview/radconfirm-on-radtreeview-nodeclick.aspx
window.blockConfirm =
function
(text, mozEvent, oWidth, oHeight, callerObj, oTitle)
{
var
ev = mozEvent ? mozEvent : window.event;
//Moz support requires passing the event argument manually
//Cancel the event
ev.cancelBubble =
true
;
ev.returnValue =
false
;
if
(ev.stopPropagation) ev.stopPropagation();
if
(ev.preventDefault) ev.preventDefault();
//Determine who is the caller
var
callerObj = ev.srcElement ? ev.srcElement : ev.target;
//Call the original radconfirm and pass it all necessary parameters
if
(callerObj)
{
//Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again.
var
callBackFn =
function
(arg)
{
if
(arg)
{
callerObj[
"onclick"
] =
""
;
if
(callerObj.click) callerObj.click();
//Works fine every time in IE, but does not work for links in Moz
else
if
(callerObj.tagName ==
"A"
)
//We assume it is a link button!
{
try
{
eval(callerObj.href)
}
catch
(e)
{
}
}
}
}
radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
}
return
false
;
}
function
RadContextMenu_ItemClicking(sender, eventArgs)
{
var
item = eventArgs.get_item();
if
(item.get_text().substring(0, 7).toLowerCase() ==
"publish"
)
{
//display radconfirm popup
return
blockConfirm(
'message'
, eventArgs, 340, 100,
''
,
'Confirm Publish'
);
}
if
(item.get_text().substring(0, 7).toLowerCase() ==
"version"
|| item.get_text().substring(0, 7).toLowerCase() ==
"publish"
)
{
eventArgs.set_cancel(
true
);
}
else
{
//disable all context menus
<asp:Literal ID=
"LiteralDisableContextMenu"
runat=
"server"
/>
}
}
I am pretty sure the problem is with the eventArgs variable that I am sending the blockConfirm. I have the blockConfirm working on a different part of my project when triggered from an ImageButton and that call is:
return
blockConfirm(
'Are you sure you want to delete this item?'
, event, 340, 100,
''
,
'Confirm Delete?'
);
When I try using the variable "event" with the onclientclicking I get an error saying it does not exist. So what do I need to do to make this work with a RadMenuItem?
I read on the forums and could not find any answer, however this has been asked before here: http://www.telerik.com/community/forums/aspnet-ajax/treeview/radconfirm-on-radtreeview-nodeclick.aspx