I am getting the error in the Telerik code:
tree._contextMenu[undefined] is not a function. Its probably due to this line:
var lastContext = null;
Anybody to give suggestion/help?
<
script
type
=
"text/javascript"
language
=
"javascript"
>
function ClientMouseOver(sender, e) {
var contextMenu = $find("<%= completedContextMenu.ClientID %>");
if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) {
contextMenu.show(e);
}
$telerik.cancelRawEvent(e);
}
function pageLoad() {
if (document.getElementById('<%= hdnVisited.ClientID %>').value == "") {
var popup = $find('<%= pnlMessagePopup.ClientID %>');
if (popup != null) {
popup.show();
document.getElementById('<%= hdnVisited.ClientID %>').value = "visited";
}
}
// for context menu
if ($telerik.isMobileSafari) {
//var treeArea = $telerik.$($find('tvCompletedCourses').get_element())[0];
var treeArea = document.getElementById('<%= tvCompletedCourses.ClientID %>');
alert(treeArea);
treeArea.addEventListener('touchstart', handleTouchStart, false);
treeArea.addEventListener('touchend', handleTouchEnd, false);
}
}
function closePopup() {
var popup = $find('<%= pnlMessagePopup.ClientID %>');
if (popup != null) {
popup.close();
}
}
var lastContext = null;
var longTouchID = 0;
var menuShown = false;
function longTouch() {
longTouchID = 0;
menuShown = true;
var tree = document.getElementById('<%= tvCompletedCourses.ClientID %>');
tree._contextMenu(lastContext);
}
function handleTouchStart(e) {
lastContext = e;
lastContext.button = 2;
lastContext.target = e.originalTarget;
lastContext.eventMapTarget = lastContext.target;
lastContext.pageX = e.changedTouches[0].pageX;
lastContext.pageY = e.changedTouches[0].pageY;
lastContext.clientX = e.changedTouches[0].clientX;
lastContext.clientY = e.changedTouches[0].clientY;
longTouchID = setTimeout(longTouch, 1000);
}
function handleClick(e) {
if (menuShown) {
menuShown = false;
document.body.removeEventListener('click', handleClick, true);
e.stopPropagation();
e.preventDefault();
}
}
function handleTouchEnd(e) {
if (longTouchID != 0)
clearTimeout(longTouchID);
if (menuShown) {
document.body.addEventListener('click', handleClick, true);
e.preventDefault();
}
}
</
script
>