I use a RadContextMenu that I load programmatically with javascript when the user right-clicks. This has worked perfectly for some time. However, since I loaded the new (2010 Q2) build, now when I open the menu more than once the items loaded into the menu are always added onto the items that were already there even though I am calling the get_items().clear() function.
The snippet below is from a simple project that demonstrates the problem:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript">
function showMenu(contextMenu, e) {
contextMenu.trackChanges();
contextMenu.get_items().clear();
var item = new Telerik.Web.UI.RadMenuItem();
item.set_text('Sampl Item 1');
contextMenu.get_items().add(item);
var item = new Telerik.Web.UI.RadMenuItem();
item.set_text('Sampl Item 2');
contextMenu.get_items().add(item);
var item = new Telerik.Web.UI.RadMenuItem();
item.set_text('Sampl Item 3');
contextMenu.get_items().add(item);
contextMenu.commitChanges();
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="div1" style="width: 400px; height: 100px; border: solid 1px Black">
Click here to see context menu
</div>
<telerik:RadContextMenu ID="RadContextMenu1" Runat="server" OnClientShowing="showMenu">
<Targets>
<telerik:ContextMenuElementTarget ElementID="div1" />
</Targets>
</telerik:RadContextMenu>
</form>
</body>
</html>
This simple page worked perfectly prior to updating my control library to 2010 Q2.
The snippet below is from a simple project that demonstrates the problem:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript">
function showMenu(contextMenu, e) {
contextMenu.trackChanges();
contextMenu.get_items().clear();
var item = new Telerik.Web.UI.RadMenuItem();
item.set_text('Sampl Item 1');
contextMenu.get_items().add(item);
var item = new Telerik.Web.UI.RadMenuItem();
item.set_text('Sampl Item 2');
contextMenu.get_items().add(item);
var item = new Telerik.Web.UI.RadMenuItem();
item.set_text('Sampl Item 3');
contextMenu.get_items().add(item);
contextMenu.commitChanges();
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="div1" style="width: 400px; height: 100px; border: solid 1px Black">
Click here to see context menu
</div>
<telerik:RadContextMenu ID="RadContextMenu1" Runat="server" OnClientShowing="showMenu">
<Targets>
<telerik:ContextMenuElementTarget ElementID="div1" />
</Targets>
</telerik:RadContextMenu>
</form>
</body>
</html>
This simple page worked perfectly prior to updating my control library to 2010 Q2.