简体   繁体   English

Href链接无法正确呈现

[英]Href link is not rendering properly

I am using Kendo Menu bar to call javascript function on the click of Menu Item. 我正在使用Kendo菜单栏,在单击菜单项时调用javascript函数。 But url of Kendo Menu is not rendering properly. 但是Kendo Menu的url无法正确显示。 Below is the code 下面是代码

function kendoMenu() {
    $('#menu').kendoMenu({
        //orientation: "vertical",
        dataSource: [
            {
                text: "Export",
                value: "newtransaction",
                items: [
                    {
                        text: " Managers",
                        value: "managers",
                        url: "javascript:ImportExport('OFD')"
                    },
                    {
                        text: " Terms",
                        value: "terms",
                        url: "javascript:doImportExport('OFI')"
                    },
                ]
            },
        ],
       // select: onKendoMenuselect
    });
}

But when i run the program, on the html side it is rendering as 但是当我运行程序时,在html端它呈现为

<a class="k-link" href="javascript:ImportExport(" ofi')'=""> Terms</a>

But i want href to be rendered as: 但我希望href呈现为:

<a class="k-link" href="javascript:ImportExport('ofi')"> Terms</a>

What should be the best approach? 最好的方法是什么? Thanks for the help in advance. 我在这里先向您的帮助表示感谢。

you can do that in select event try the code below. 您可以在选择事件中尝试以下代码。

$('#menu').kendoMenu({
    //orientation: "vertical",
    dataSource: [
        {
            text: "Export",
            value: "newtransaction",
            items: [
                {
                    text: " Managers",
                    value: "managers"
                },
                {
                    text: " Terms",
                    value: "terms"
                },
            ]
        },
    ],
   function onMenuSelect(ev) {
      var selected=ev.item.textContent;
      if(selected == "Managers"){
         window.location.href='your url here';
      }
      else
      {
           and so on...
      }
   }
});

Escape quotes inside string using backslash ( \\ ) 使用反斜杠( \\ )在字符串内转义引号

url: "javascript:ImportExport(\"OFD\")"

url: "javascript:doImportExport(\"OFI\")"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM