将jQuery UI函数与Mithril结合使用

编程入门 行业动态 更新时间:2024-10-12 10:25:36
本文介绍了将jQuery UI函数与Mithril结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是Mithril JS框架的新手,我喜欢它的渲染性能.轻巧是一个加号,但我想使用jQuery UI,以便可以从其某些功能(例如可拖动的交互)中受益.据我了解,jQuery UI和Mithril都可以操作DOM元素.如果是这样,将jQuery UI与Mithril一起使用有多实用?

I am new to the Mithril JS framework and I love its rendering performance. It being light-weight is a plus, but I would like to use jQuery UI so that I can benefit from some of its functionality such as the draggable interaction. From my understanding, both jQuery UI and Mithril manipulate DOM elements. If so, how practical is it to use jQuery UI with Mithril?

推荐答案

您的问题有点悬而未决,但要给出一个有用的答案:秘银模板实际上不会触及DOM,直到您调用m.render,m.module或m.route.完成后,差异引擎会根据需要创建或更新元素以镜像模板的结构.您可以在模板中使用config来获取真实的DOM元素,并在其上运行jQuery/jQuery UI:

Your question is a bit open ended, but to give a useful answer: Mithril templates don't actually touch the DOM until you call either m.render, m.module or m.route. When you do, the diff engine creates or updates elements as needed to mirror the structure of the template. You can use config in templates to get to real DOM elements, and run jQuery/jQuery UI on them:

function draggable(element, isInitialized) { if (!isInitialized) $(element).draggable() } var module = {} module.controller = function() { this.greeting = "Hello" } module.view = function(ctrl) { m("div", {config: draggable}, ctrl.greeting) } m.module(document.body, module)

更多推荐

将jQuery UI函数与Mithril结合使用

本文发布于:2023-10-28 04:45:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535563.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   jQuery   UI   Mithril

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!