如何使用Telerik UI .ASP .NET在悬停时隐藏子菜单?

huangapple go评论48阅读模式
英文:

How can i hide the submenu on hover using Telerik UI .ASP .NET

问题

我使用Telerik UI for .ASP.NET创建了一个菜单。当我将鼠标悬停在菜单上时,它会自动显示子菜单。

我想要只有在单击主菜单项时才显示子菜单,而不是悬停。

这是我尝试过的内容,但没有按预期工作。

$("li.k-menu-item").hover(function (e) {
    $(this).children("div.k-animation-container").css("display", "none");
    $(this).children("div.k-animation-container").removeClass("k-animation-container-active");
});
英文:

I've created a menu using Telerik UI for .ASP.NET. When I hover over the menu, it automatically shows the submenu.

I would like to show the submenu only when the main item is clicked, not hovered.

@(Html.Kendo().Menu()
  .Name("menu-navbar")
  .HtmlAttributes(new { @style = "margin-top: 10px;" })
  .Items(items =>
  {
    items.Add()
      .Url(Url.Action("Index", "Menu", new { parentId = Request["parentId"], menuItemId = Request["menuItemId"] }))
      .Text(
        "<i class='glyphicon glyphicon-home' style='margin-right: 3px; color: white'></i>" +
        G("NavbarHome")
      )
      .HtmlAttributes(new { @class = "nav navbar-nav navbar-inverse" })
      .Encoded(false);

    items
      .Add()
      .Text("ESECUZIONE <span class='caret'></span>")
      .Encoded(false)
      .Items(subItems =>
      {
        subItems.Add()
          .Url(Url.Action("Update", "DataUpdates"))
          .Text(@G("NavbarImportData" + ""))
          .Encoded(false);


        subItems.Add()
          .Url(Url.Action("UpdateImport", "DataUpdates"))
          .Text(@G("NavbarImport" + ""))
          .Encoded(false);

        subItems.Add()
          .Url(Url.Action("Index", "DataTablesDelete"))
          .Text(@G("NavbarDelete"))
          .Encoded(false);
      });
  })

This is what I tried, but it didn't work as expected.

$("li.k-menu-item").hover(function (e) {
    $(this).children("div.k-animation-container").css("display", "none");
    $(this).children("div.k-animation-container").removeClass("k-animation-container-active");
});

答案1

得分: 1

我搞清楚了。
我只需要将这个添加到主菜单。

OpenOnClick(true)

来源:https://docs.telerik.com/aspnet-mvc/api/kendo.mvc.ui.fluent/menubuilder#openonclicksystemboolean

英文:

I figured it out.
I only needed to add this to the main menu.

OpenOnClick(true)

source: https://docs.telerik.com/aspnet-mvc/api/kendo.mvc.ui.fluent/menubuilder#openonclicksystemboolean

huangapple
  • 本文由 发表于 2023年7月17日 17:44:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76703220.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定