1

I've created a complex template using JsRender with a bunch of nested tables. Now I'm transitioning to using JsViews so that I can take advantage of data-binding+incremental DOM updates (so that I don't have to re-render the entire template). However, I get an interesting error:

screen-shot-of-error

This problem goes away if I make sure each tr is within any of thead, tbody, or tfoot, as long as the tr is not a direct child of table. So my question is this: where did this design decision for JsViews come from? Why impose this constraint?

Thanks in advance.

jsviews.js:83 badParent = {tr: "table"}
4

1 回答 1

1

是的,正如 JcFx 在上面的评论中所说,这是在这里回答的。

正如我所说,JsViews 与 DOM 元素层次结构一起工作。浏览器可以通过几种方式动态地将 DOM 更改为规范形式,例如插入 TBODY,即使您没有在标记中放一个 TBODY。

通过让 JsViews 尝试自动补偿这一点,而不是添加大量代码、性能命中和潜在的错误风险,JsViews 在大多数情况下会向您提供错误消息,它检测到您的标记格式不正确或不正确尊重这些“规范规则”——即错过了一个 TBODY ......

于 2013-05-16T17:23:22.913 回答