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

Setting LinkHtmlAttributes in Model Bound Menus

1 Answer 355 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 1
Drew asked on 26 Jul 2012, 08:10 PM
I've got a menu bound to a model but I can't seem to set the LinkHtmlAttributes.

It looks like this:


@(Html.Kendo().Menu()
    .Name("menu")
    .BindTo(Model, mappings =>
        {
            mappings.For<MenuModel>(binding => binding
                .ItemDataBound((items, menu) =>
                    {
                        items.Text = menu.Text;
//I want to set the link attributes, but this isn't working
items.LinkHtmlAttributes = new { foo = "bar" };
                    })
)

1 Answer, 1 is accepted

Sort by
0
Ignacio
Top achievements
Rank 1
answered on 11 Oct 2013, 07:33 PM
You dont need to new up the Dictionary, just add elements to it. Like so:

@(Html.Kendo().Menu()
    .Name("menu")
    .BindTo(Model, mappings =>
        {
            mappings.For<MenuModel>(binding => binding
                .ItemDataBound((items, menu) =>
                    {
                        items.Text = menu.Text;
            //I want to set the link attributes, but this isn't working
            items.LinkHtmlAttributes.Add("data-foo", "bar");
                    })
    )
Tags
Menu
Asked by
Drew
Top achievements
Rank 1
Answers by
Ignacio
Top achievements
Rank 1
Share this question
or