【发布时间】:2011-08-09 15:42:39
【问题描述】:
private static IDictionary<string, object> CreateBindAttribute<TModel, TProperty>(Expression<Func<TModel, TProperty>> expression)
{
string exp = ExpressionHelper.GetExpressionText(expression);
var htmlAttributes = new Dictionary<string, object>();
// knockout uses data-bind to bind the UI to the viewModels
htmlAttributes.Add("data-bind", "value: " + exp + ", uniqueName: true");
return htmlAttributes;
}
public static MvcHtmlString KoPasswordFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
{
//return htmlHelper.PasswordFor(expression, CreateBindAttribute(expression));
return htmlHelper.PasswordFor(expression,);
}
上面的代码突出了我的问题。 我有一个 knockoutJS html 助手,它向标记添加了“数据绑定”属性。但是,我发现该字段上的验证消息不起作用。
如果我评论呈现绑定属性的重载,则验证消息显示正常。请注意,验证仍然适用于注释掉的行,但下面的验证文本不显示。
谁能确认这种行为,如果可以,如何解决?
【问题讨论】:
标签: jquery asp.net-mvc-3 knockout.js