This question is locked. New answers and comments are not allowed.
Brian Mains
Top achievements
Rank 1
Brian Mains
asked on 04 Dec 2009, 05:38 PM
Hello,
For hyperlinks in the RadMenu, I need to append target="_blank" to them, but I can't figure out a good approach for this. What approach do I use to do this?
Thanks.
For hyperlinks in the RadMenu, I need to append target="_blank" to them, but I can't figure out a good approach for this. What approach do I use to do this?
Thanks.
5 Answers, 1 is accepted
0
Accepted
Hi Brian Mains,
.ClientEvents(events => events.OnLoad(() => {
%>
function (e) {
$(this).find('a').attr('target', '_blank');
}
<%}))
Regards,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Unfortunately we have not exposed a way to set the html attributes of the link generated for a menu item. I have added this as a feature request and we will implement it soon. The api would probably be
items.Add("Text").LinkHtmlAttributes(new { target="_blank" }));
For now the only workaround is to set the target with JavaScript using the OnClientLoad event:.ClientEvents(events => events.OnLoad(() => {
%>
function (e) {
$(this).find('a').attr('target', '_blank');
}
<%}))
Regards,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Brian Mains
Top achievements
Rank 1
answered on 07 Dec 2009, 07:06 PM
Hello,
Thanks. I modified it, for the benefit of someone else who may read this, I needed only a subset of the links to open in new windows. To do this, I appended a css class to the parent list item (which is set by the HtmlAttributes collection). It adds a class to the list item that makes up the menu (under the scenes, it uses a UL element). Then, I changed the JQuery statement to be:
$(this).find("li.MyTargetedLink > a").attr("target", "_blank");
And that worked perfectly.
Thanks again.
Thanks. I modified it, for the benefit of someone else who may read this, I needed only a subset of the links to open in new windows. To do this, I appended a css class to the parent list item (which is set by the HtmlAttributes collection). It adds a class to the list item that makes up the menu (under the scenes, it uses a UL element). Then, I changed the JQuery statement to be:
$(this).find("li.MyTargetedLink > a").attr("target", "_blank");
And that worked perfectly.
Thanks again.
0
FENG Zhichao
Top achievements
Rank 1
answered on 08 Dec 2009, 04:27 PM
.LinkHtmlAttributes() would be very useful :)
0
Brian Mains
Top achievements
Rank 1
answered on 20 Dec 2009, 03:55 AM
Hello,
Does the ItemAction() method which takes a menuitem passed in, which has a LinkHtmlAttributes method, is this the same as the proposed solution?
Thanks.
Does the ItemAction() method which takes a menuitem passed in, which has a LinkHtmlAttributes method, is this the same as the proposed solution?
Thanks.
0
Hi Brian Mains,
Yes. It is the same. You can use this code for example:
.ItemAction(item => item.LinkHtmlAttributes.Add("target", "_blank"))
Regards,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Yes. It is the same. You can use this code for example:
.ItemAction(item => item.LinkHtmlAttributes.Add("target", "_blank"))
Regards,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.