惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
AI
AI
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
博客园 - 【当耐特】
V
Visual Studio Blog
博客园 - Franky
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
I
Intezer
C
Cybersecurity and Infrastructure Security Agency CISA
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
SegmentFault 最新的问题
腾讯CDC
T
Threat Research - Cisco Blogs
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Webroot Blog
Webroot Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
小众软件
小众软件
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News: Ask HN
Hacker News: Ask HN
T
Tor Project blog
WordPress大学
WordPress大学
雷峰网
雷峰网
J
Java Code Geeks
GbyAI
GbyAI
Recorded Future
Recorded Future
F
Full Disclosure
Cisco Talos Blog
Cisco Talos Blog
S
Secure Thoughts
I
InfoQ
量子位
Forbes - Security
Forbes - Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threatpost
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
Attack and Defense Labs
Attack and Defense Labs
爱范儿
爱范儿
N
News and Events Feed by Topic
V
Vulnerabilities – Threatpost
L
LINUX DO - 最新话题
A
Arctic Wolf
S
Security Affairs

博客园 - 山不转水转...

Windbg的First chance exception WPF 文本框焦点导致的内存泄露问题 产品功能被像素级抄袭了。我们拿什么来保护原创的产品设计? 显示器文字发虚的一种原因 HttpClient + IIS压缩动态内容 Windows 上第一款全局轮盘菜单软件(鼠标党进) C# Async Await 注意事项 MVC6的内置ActionResult类型 将long数字序列化为json时,转换为字符串 共享一个在线代码片段收集服务 清除ASPX页面中的meta:resourceKey="[a-zA-Z0-9]+" MVC 多语言记录1 设置默认的ResourceType 查询SQL Server中所有数据库的数据文件位置 那些年,我做共享软件(3)完结 那些年,我做共享软件(2) 那些年,我做共享软件(1) URTracker事务跟踪系统在软件企业中的应用 浅析缺陷管理系统URTracker 问题跟踪软件URTracker和Windows域的集成
knockoutjs with绑定导致unobtrusive validation失效的问题
山不转水转... · 2013-09-02 · via 博客园 - 山不转水转...

2013-09-02 22:42  山不转水转...  阅读(318)  评论()    收藏  举报

如果最初的时候with绑定的对象是空的,那么with绑定内部的unobtrusive validation规则在提交的时候无法生效,无法进行验证。

解决办法:

在提交的时候(或者with绑定的对象非空值以后),先清除form对象的'validation'的data:

$.removeData($form[0], 'validator');

然后调用unobtrusive validation的parse函数重新对form内的控件进行解析。

$.validator.unobtrusive.parse($form[0]);

再调用valid()函数就可以正常验证了。

with绑定的对象为空的时候,还会导致form内button(或其他控件)的jquery的事件处理代码不能正常触发。需要把button移动到with绑定范围之外。

 knockoutjs 对with 的说明:

If the expression you supply evaluates to null or undefined, descendant elements will not be bound at all, but will instead be removed from the document.

If the expression you supply involves any observable values, the expression will be re-evaluated whenever any of those observables change. Then, descendant elements will be cleared out, and a new copy of the markup will be added to your document and bound in the context of the new evaluation result.