I am using telerik in an application I am creating, and i have a javascript on.click
method which runs when an item is clicked in a telerik:RadContextMenu
.
<telerik:RadContextMenu ID="tkDocumentList" runat="server" OnClientItemClicking="DocumentListOnClientItemClicking">
<Items>
<telerik:RadMenuItem Text="Edit Document" />
<telerik:RadMenuItem Text="Delete Document" />
<telerik:RadMenuItem Text="Upload Document" />
<telerik:RadMenuItem Text="Download Document" />
<telerik:RadMenuItem IsSeparator="True" />
</Items>
</telerik:RadContextMenu>
The function determines which item was checked and then executes some logic.
function DocumentListOnClientItemClicking(sender, args) {
var index = args.get_item().get_index();
if (index == 0) {
console.log('Toggle in edit');
$('.documentdetails>.modalContent').toggleClass('show');
$('.showedit').val("true");
}
else if (index == 1) {
var result = confirm("Are you sure you want to delete this item?");
args.set_cancel(!result);
sender.hide();
}
else if (index == 2) {
console.log('Toggle in upload');
$('.documentdetails>.modalContent').toggleClass('show');
}
}
My problem is that when the index is 0 it goes into the if and else if, ill try to explain my problem. Imagine function DocumentListOnClientItemClicking(sender, args) {
is line:0
and the final ending }
is line: 16
. Here is how this method executes:
- 1 (Index is 0)
- 2
- 3
- 4
- 5
- 6
- 7 (index is not 1)
- 11
- 12 (index is not 2, however it runs part of this else if)
- 14 (doesnt hit console log and break on this line)
Does anyone know why this might be happening?