using @data-bind in ASP.NET MVC htmlAttributes throws exception

后端 未结 2 1575
别跟我提以往
别跟我提以往 2021-02-19 14:39

I am using ASP.NET MVC 3.0 and KnockoutJS. I was trying to add the binding into my View Helpers like this ...

@Html.TextBoxFor(model => model.Nam         


        
2条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 15:30

    If you are using MVC2, you can use the following jquery function to change the data_bind to data-bind:

            // MVC2 fix for data_bind
            $('[data_bind]').each(function(i, item) {
                item = $(item);
                item.attr("data-bind",item.attr("data_bind"));
                item.removeAttr("data_bind");
            });
    

提交回复
热议问题