[英]How to force Mithril to redraw without diffing? (integrating dragula in Mithril)
I am translating a JQuery-based app to Mithril.我正在将一个基于 JQuery 的应用程序翻译成 Mithril。 That app uses Dragula to allow drag/drop to reorder lists.
该应用程序使用 Dragula 允许拖放以重新排序列表。
li
elements in the DOM. li
元素重新排序。 However, the UI ends up in a mixed state:但是,UI 最终会出现混合的 state:
<li data-idx="0"> The Zero </li>
<li data-idx="1"> The One </li>
and after user dragging 1 before 0, it ends up as:并且在用户将 1 拖到 0 之前,它最终为:
<li data-idx="1"> The One</li>
<li data-idx="0"> The Zero</li>
Tried:试过:
m.redraw(), m.redraw.sync(), they correctly work but if ie. m.redraw(),m.redraw.sync(),它们可以正常工作,但如果即。 the LIs are moved by dragula, then the resulting HTML is in a mixed state.
LI 由 Dragula 移动,然后生成的 HTML 位于混合 state 中。
clearing dom
in vnode
with the hope it would be recreated.清除
vnode
中的dom
,希望能重新创建它。
vmode.dom.textContent
vmode.dom.textContent
... And nothing changes, either I get a blank widget or the values in "data-idx" are still wrong. ...并且没有任何变化,要么我得到一个空白小部件,要么“data-idx”中的值仍然错误。
So my question is, in general, is it possible, and how, to use these kind of libraries that manipulate a mithril widget inner html, and then call m.redraw() so mithril re-renders the mess?所以我的问题是,一般来说,是否有可能以及如何使用这些库来操作内部 html 的秘银小部件,然后调用 m.redraw() 以便秘银重新渲染混乱?
Background:背景:
My widgets are mounted with route:我的小部件安装有路线:
"/videos": { “/视频”:{
onmatch: () => loginWall(true), render: v => m(layoutWidget, m(videosWidget, v.attrs)) },
This is an older post but maybe you could provide more information about how the components are created in the videosWidget
.这是一篇较旧的帖子,但也许您可以提供有关如何在
videosWidget
中创建组件的更多信息。 Mithril usually needs a key to distinguish between elements so that the current dom state is maintained as the model list changes as explained here: keys .秘银通常需要一个键来区分元素,以便在 model 列表更改时维护当前的 dom state,如下所述: keys 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.