何时在 Backbone 视图中附加 jQuery 插件

发布于 2025-01-05 16:42:02 字数 192 浏览 4 评论 0原文

我正在尝试找出附加 jQuery 插件和一些基本 UI 设置功能的最佳且最便宜的方法。

目前,我可以想到两种方法:

1)渲染视图后触发函数。这意味着每次渲染视图时,都会重新附加插件等。这会导致内存等问题吗?

2)以某种方式模仿插件的 jQuery .live()...我不知道这是否可能有

什么想法吗?

I am trying to figure out the best and most inexpensive way to attach jQuery plugins and some basic UI setup functions.

Currently, I can think of two ways:

1) Fire a function after rendering the view. This means that each time the view is rendered, the plugins, etc are re-attached. Could this cause memory, etc issues?

2) Somehow mimic jQuery .live() for plugins... I don't know if that's even possible

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

她说她爱他 2025-01-12 16:42:02

请记住, jQuery.live 已弃用,您应该使用 jQuery.on 代替,请参阅:http://api.jquery.com/delegate/
无论如何,您可能会在这里找到一些有趣的解决方案:使用 jQuery 检测元素内容更改

Keep in mind that jQuery.live is deprecated and you should use jQuery.on instead, see: http://api.jquery.com/delegate/
Anyway you may find some interesting solutions here: Detect element content changes with jQuery

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文