This question is locked. New answers and comments are not allowed.
Hello,
I have created a menu like the following:
<%= Html.Telerik().Menu()
.Name("menu")
.Orientation(MenuOrientation.Horizontal)
.Items(items => {
items.Add().Text("Page 1")
.Action("Show", "Home", new {goto_page = "1"})
.Enabled(ViewData["current_page"].ToString()!="1");
items.Add().Text("Page 2")
.Action("Show", "Home", new { goto_page = "2"})
.Enabled(ViewData["current_page"].ToString() != "2");
})
%>
So, when ViewData["current_page"] contains "1", the menu item "Page 1" will be disabled.
When ViewData["current_page"] contains "2", the menu item "Page 2" will be disabled.
The UI looks good at run-time. Yet when I click on the disabled-menu-item, a call is actually made to the controller, which is not expected. I wonder if I'm missing something.
When the user clicks on a disabled-menu-item, how can we stop the menu to call the controller at all?
Many thanks!
I have created a menu like the following:
<%= Html.Telerik().Menu()
.Name("menu")
.Orientation(MenuOrientation.Horizontal)
.Items(items => {
items.Add().Text("Page 1")
.Action("Show", "Home", new {goto_page = "1"})
.Enabled(ViewData["current_page"].ToString()!="1");
items.Add().Text("Page 2")
.Action("Show", "Home", new { goto_page = "2"})
.Enabled(ViewData["current_page"].ToString() != "2");
})
%>
So, when ViewData["current_page"] contains "1", the menu item "Page 1" will be disabled.
When ViewData["current_page"] contains "2", the menu item "Page 2" will be disabled.
The UI looks good at run-time. Yet when I click on the disabled-menu-item, a call is actually made to the controller, which is not expected. I wonder if I'm missing something.
When the user clicks on a disabled-menu-item, how can we stop the menu to call the controller at all?
Many thanks!
12 Answers, 1 is accepted
0
Hi Nim,
Hristo Germanov
the Telerik team
Thank you for the contacting us.
I confirm it is a bug, which will be fixed with next official release of Telerik Components for ASP.NET MVC (Q1 2011).
I have updated your Telerik points.
Hristo Germanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
chani diakidis
Top achievements
Rank 1
answered on 02 Apr 2012, 03:10 PM
sorry to revive an old post.. but have you fixed this bug? I’m still experiencing the same behaviour with v2012.1.214 when disabling the menu item through the code and the markup
regards.
0
Hi Chani,
Yes, the bug is fixed now, please make sure you have upgraded correctly and using the latest DLL and scripts.
Regards,
Dimo
the Telerik team
Yes, the bug is fixed now, please make sure you have upgraded correctly and using the latest DLL and scripts.
Regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Eva
Top achievements
Rank 1
answered on 12 Apr 2012, 10:50 PM
I just upgraded to the latest version and I am still having this issue. The button appears disabled but when you click it, it fires the click event. I think this is not actually fixed.
Eva
Eva
0
Hello Eva,
Yes, a disabled Menu item will still fire click events and this is expected in this implementation. However...
1. If the Menu item has a hyperlink, it will not navigate, which was the initial discussion about and this is what we fixed
2. Generally, we cannot prevent the click event from firing, because we do not use the disabled HTML attribute, as it is not applicable for <span> and <a> elements
3. You seem to be using a custom click handler, so you can easily check in it whether the item is disabled or not by checking whether the item's <li> element has a t-state-disabled CSS class.
Kind regards,
Dimo
the Telerik team
Yes, a disabled Menu item will still fire click events and this is expected in this implementation. However...
1. If the Menu item has a hyperlink, it will not navigate, which was the initial discussion about and this is what we fixed
2. Generally, we cannot prevent the click event from firing, because we do not use the disabled HTML attribute, as it is not applicable for <span> and <a> elements
3. You seem to be using a custom click handler, so you can easily check in it whether the item is disabled or not by checking whether the item's <li> element has a t-state-disabled CSS class.
Kind regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Eva
Top achievements
Rank 1
answered on 13 Apr 2012, 01:32 PM
Oh yeah, that makes complete sense and of course! Thank you!
I actually have disabled the click event myself, I just thought I would share it here since I saw the thread, but you are right, you can't read our minds :) Perfect!
I actually have disabled the click event myself, I just thought I would share it here since I saw the thread, but you are right, you can't read our minds :) Perfect!
0
chani diakidis
Top achievements
Rank 1
answered on 13 Apr 2012, 05:17 PM
thanks for the reply and help.
just as a reference for the others who want the same functionality using custom click event, the solution, as also mentioned above, is as follow inside your event handler:
regards,
just as a reference for the others who want the same functionality using custom click event, the solution, as also mentioned above, is as follow inside your event handler:
if ($(e).hasClass('t-state-disabled')) { return false; }
regards,
0
Atanu
Top achievements
Rank 1
answered on 28 Jul 2012, 04:33 PM
if ($(e).hasClass('t-state-disabled')) is not working in my case. I am trying to disable a menu from jquery like menu.disable(domElement);The generated htmlvarmenu = $("#MyMenu").data("tMenu");vartotMenu = $("> li", menu.element).length;for(varintCnt = 0; intCnt < totMenu; intCnt++) {domElement = $("> li", menu.element)[intCnt].childNodes[0];if(domElement.innerText =="Test")menu.disable(domElement);}<liclass="t-item t-state-default"style="float: right"><spanclass="t-link">Test</span></li>Though it makes the item looks disabled visually but keep the class="t-item t-state-default".Don't know why ? So the t-state-disabled cannot be checked. I think this is big issue if anyone is working with Telerik menus.
0
Hello Atanu,
The Javascript code is wrong on the following line:
Please review the Menu's client API demo and documentation once again and compare with your implementation.
Regards,
Dimo
the Telerik team
The Javascript code is wrong on the following line:
domElement = $("> li", menu.element)[intCnt].childNodes[0];Please review the Menu's client API demo and documentation once again and compare with your implementation.
Regards,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Atanu
Top achievements
Rank 1
answered on 30 Jul 2012, 08:09 AM
What's wrong ?
Its working fine at my end. Will you please put some more light on it.
Any way I have solved the issue by some other way but still wanted to know the error.
Thanks
Its working fine at my end. Will you please put some more light on it.
Any way I have solved the issue by some other way but still wanted to know the error.
Thanks
0
Hi Atanu,
You should pass <li> elements to the Menu's enable() and disable() methods, not the <span> elements inside.
Kind regards,
Dimo
the Telerik team
You should pass <li> elements to the Menu's enable() and disable() methods, not the <span> elements inside.
Kind regards,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Atanu
Top achievements
Rank 1
answered on 31 Jul 2012, 04:42 AM
Gr8.. Thanks buddy
