为什么Kendo View上的“显示”事件会触发两次?

时间:2019-05-23 00:15:04

标签: kendo-ui

如果将Kendo View渲染到Layout中(使用layout.showIn()),则该视图的show事件将触发两次。 有趣的是,如果将视图直接渲染到DOM元素中(使用view.render()),则该事件仅被触发一次,就像应该触发的那样。

该代码可以很好地从Kendo UI Dojo东西中复制。 我想知道您是否可以运行此命令: https://dojo.telerik.com/AkOwiMAZ/2

<div id="app"></div>
<script>
var foo = new kendo.View("<span>Foo</span>", { hide: function() { console.log("Foo is hidden now"); }, show: function() { console.log( "Foo is shown now"); }});

var layout = new kendo.Layout("<header>Header</header><section id='content'></section><footer></footer>");

// Creating the layout, and using the showIn method to render the view
// is where I'm having the issue (2 'show' events fire)
layout.render($("#app"));
layout.showIn("#content", foo);
//
// But this way works fine (rendering directly to a DOM element) (just // one 'show' event fires)
//foo.render('#app');
</script>

我希望触发一次'show'事件,因为该事件仅显示一次:)

1 个答案:

答案 0 :(得分:2)

这似乎是最新的2019 R2 kendo版本(2019.2.514)中引入的错误。将样本切换为使用以前的2019 R1 SP1(2019.1.220)版本会导致其行为符合预期https://dojo.telerik.com/AkOwiMAZ/5

Telerik通常在每个季度发布大约一个月后发布一个Service Pack;我们已经向他们提出了一个错误报告,因此可能会在2019 R2 SP1中修复它。否则,我猜你最好的选择是暂时坚持2019.1.220。希望这会有所帮助。

相关问题