1

I am using Kendo Menu bar to call javascript function on the click of Menu Item. But url of Kendo Menu is not rendering properly. 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

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

But i want href to be rendered as:

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

What should be the best approach? Thanks for the help in advance.

Alfin Paul
  • 1,543
  • 14
  • 26
Rupak
  • 61
  • 10
  • 1
    Try escaping quote `url: "javascript:ImportExport(\"OFD\")"` – Zahid Zuhair Aug 14 '18 at 10:54
  • @ZahidZuhair hey thanks for the solution..could you pls write it as answer so that i can select this as solution and will be helpful for others – Rupak Aug 16 '18 at 05:37

2 Answers2

0

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...
      }
   }
});
N.Siva
  • 66
  • 5
0

Escape quotes inside string using backslash (\)

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

url: "javascript:doImportExport(\"OFI\")"
Zahid Zuhair
  • 136
  • 1
  • 2
  • 9