简体   繁体   English

JSViews与转换器的可见链接不起作用

[英]JSViews visible link with converter doesn't work

I upgraded to the latest version of JsViews and it seems like something broke. 我已升级到最新版本的JsViews,似乎有些问题。

If I have a data-link like "visible{:property}", it works. 如果我有一个像“ visible {:property}”这样的数据链接,它就可以工作。

If I have a data-link like "visible{convert:property}", it does not work. 如果我有一个像“ visible {convert:property}”之类的数据链接,它将无法正常工作。

From what I can tell it seems like it looks early on in the process for the attr "visible" and changes it to "css-display". 据我所知,它似乎在attr“可见”过程的早期看起来并将其更改为“ css-display”。 When I have a converter, though, in propertyChangeHandler it does this line 但是,当我有一个转换器时,在propertyChangeHandler中执行此行

attr = linkCtx.attr || attr = linkCtx.attr || attr; attr; // linkCtx.attr may have been set to tag.attr during tag instantiation in renderTag //在renderTag中的标签实例化期间,linkCtx.attr可能已设置为tag.attr

That causes it to change attr back to "visible", and then in updateContent, the regex test for "css-" fails and it never sets the display property. 这导致它将attr更改回“ visible”,然后在updateContent中,“ css-”的正则表达式测试失败,并且它从不设置display属性。

Am I missing something? 我想念什么吗? Shouldn't this work? 这不行吗?

I created a fiddle that shows what I am trying to do. 我创建了一个小提琴,以显示我要做什么。 In the non-working case, instead of setting display:none, it sets visible="false" 在不工作的情况下,它不设置display:none,而是设置visible =“ false”

http://jsfiddle.net/4scbgjpx/2/ http://jsfiddle.net/4scbgjpx/2/

<script id="worksTempl" type="text/x-jsrender">
<div data-link="visible{:show}">
    <span data-link="name"></span>
</div>
</script>

<script id="failsTempl" type="text/x-jsrender">
<div data-link="visible{negate:show}">
    <span data-link="name"></span>
</div>
</script>

$.views.converters({
    "negate": function (val) { return !val; }
});

Yes, you are right - that was a bug. 是的,您是对的-那是一个错误。 It has been fixed now (commit 58), and your jsfiddle now works correctly. 现在已修复(第58次提交),并且您的jsfiddle现在可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM