不引人注目的验证不使用局部视图jQuery的标签工作 [英] Unobtrusive validation not working on jquery tabs using partial view

查看:215
本文介绍了不引人注目的验证不使用局部视图jQuery的标签工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery-UI选项卡中显示局部视图。我有一个包含的标签定义视图:

I'm using jquery-ui tabs to display partial views. I have a view that contains the tabs definition:

<ul>
    <li><a href="@Url.Action("CreateTab","Catalogue")">Create</a></li>
    ...

和它返回一个PartialView一个控制器方法CREATETAB:

And a controller method CreateTab which returns a PartialView:

public ActionResult CreateTab()
{
    var model = new StockCatalogueItemViewModel
    {
    ... populate some selectlists
    }
    return PartialView(model);

这是我验证模型属性上有datatannotations,我可以看到验证标记已经在HTML被渲染。

The model property that I'm validating has datatannotations on and I can see that the validation tags have been rendered in the HTML.

然而,客户端验证根本不点火。服务器端验证工作正常并正确显示无效的领域。

However the client-side validation simply isn't firing. The server-side validation is working fine and is correctly showing the invalid fields.

有什么错的脚本包作为验证完美的作品在其他页面(虽然没有使用局部视图),所以我只能认为这是与事实,我的上午的使用部分意见。我见过此问题相关的其他职位,但似乎没有任何帮助。请注意,我没有使用AJAX加载的局部视图。我没有做任何事情在这里复杂的,所以为什么不工作?

There is nothing wrong with the script bundles as validation works perfectly on other pages (albeit not using partial views), so I can only think it's something to do with the fact that I am using partial views. I've seen other posts related to this issue but none seem to help. Note that I'm NOT loading the partial views using ajax. I'm not doing anything complicated here, so why isn't it working?

推荐答案

既然你不使用 Ajax.BeginForm(),我是pretty确定你需要使用 $ validator.unobtrusive.parse(#ID); 在javascrpt指定有要应用于新的验证信息

Since you're not using Ajax.BeginForm(), I'm pretty sure you need to use $.validator.unobtrusive.parse("#ID); in your javascrpt to specify that there's new validator information you want applied.

这篇关于不引人注目的验证不使用局部视图jQuery的标签工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆