This is a migrated thread and some comments may be shown as answers.

Problem with dynamic navigateURL

1 Answer 138 Views
Menu
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 14 May 2015, 04:43 PM

We are using near-latest version of the product.  In our web site we have to display dynamically generated (via javascript) context menus.  We cannot generate them on the back-end because we don't know how many or what options there will be until the user takes certain actions.  However, each menu item  will come from the master menu-bar that is created on the back-end for the overall site.

When the user takes action, we use javascript to determine which menu items from the master menu-bar are needed within the context menu.  For each item, we create a new item and add it to the context menu (ps - the context menu is declaratively created on our master page's html, albeit with no menu items):

var newItem = new Telerik.Web.UI.RadMenuItem();
newItem.set_text(mainItem.get_text());
var navUrl = mainItem.get_navigateUrl();
newItem.set_navigateUrl(navUrl);

popMenu.get_items().add(newItem);

The problem is, when the navigate url is rendered, it is total mangled.

Here is an example link from the 'main' menu bar (which works perfectly):

<a class="rmLink" style="width: 268px;" href="javascript:goDnetPage('attrition_total_exempt','4829','functions/reports/front_ends/pages/HRMetrics.aspx','Report=attrition_total_exempt') "><span class="rmText">Total Attrition</span></a>

The 'value' of the href attribute, when assigned into the 'newItem' object is correct - we have console.logged it (via newItem.get_navigateUrl) and it is accurate.  However, when the menu item is rendered by the menu code, it comes out as:

 <a class="rmLink" href="javascript:goDnetPage(" '="" hrmetrics.aspx','report="attrition_total_exempt')" pages="" front_ends="" reports="" attrition_total_exempt','4829','functions=""><span class="rmText">Total Attrition</span></a>

Something, I presume within the Telerik js, is totally munging up the href value, creating additional attributes for the 'a' element as it sees fit.  I have tried replacing/escaping single ticks and slashes, but cannot seem to get it to come out right.

 Any advice would be appreciated.  Thank you.

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 19 May 2015, 10:35 AM
Hello,

I am afraid, I was not able to reproduce the issue you are experiencing. I am attaching a sample project to this reply. It contains a RadMenu and a RadContextMenu. When we right click on the RadMenu we add a new Item to the RadContextMenu and we set its Text and NavigateUrl properties, the values of which we get from one of the RadMenu Items. At my side this works as expected and the url is correctly set to the anchor element's "href" attribute as well.

Could you please try to reproduce the issue you are having in the sample project and post your modifications, so we can investigate further the possible cause for the behavior you noticed?

Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Menu
Asked by
David
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or