简体   繁体   English

在Zepto中使用select2插件

[英]Using select2 plugin with Zepto

The problem 问题

For my project I use Zepto, but I would like to use the select2 plugin for my select input elements. 对于我的项目,我使用Zepto,但是我想对我的选择输入元素使用select2插件 According to this issue this pull request it should be possibel, yet I couldn't manage to do it. 根据这个问题, 这个拉取请求应该是possibel,但是我无法做到。 I usually get the error "jQuery not defined" 我通常会收到错误"jQuery not defined"

What I have 我有的

  • I generate the form dynamicaly, but only call the plugin, once I have the whole form. 我动态生成表单,但是只有在拥有整个表单后才调用插件。
  • I use the latest select2 and Zepto version. 我使用最新的select2和Zepto版本。
  • I also have the data component included into Zepto. 我还将数据组件包含到Zepto中。
  • EDIT: Of course I have the select2 CSS included too. 编辑:当然,我也包括select2 CSS。 (if it wasn't obvious) (如果不是很明显)

What I tried 我尝试了什么

  • updating my Zepto and select2 (as the issue was 3 months old and my project was older) 更新我的Zepto和select2(因为问题是3个月大,而我的项目是旧的)
  • aliasing Zepto as jQuery. 将Zepto别名为jQuery。 If I do that, I see some DOM elements of the select and it also hides my original select element, but it still not working. 如果这样做,我会看到select的一些DOM元素,它也隐藏了我原来的select元素,但仍然无法正常工作。

Anyone else encountered this problem before or know how to solve it? 其他人之前遇到过此问题,还是知道如何解决? It would be greatly appreciated. 这将不胜感激。 Thanks. 谢谢。

Soo. 洙。 I posted the question to GitHub as an issue, and the creator of the plugin Igor Vaynberg said that I misunderstood the linked issues, as they didn't mean select2 woud support Zepto, they only meant it will be easier to support, if it will be supported some time in the future. 我将问题作为问题发布到GitHub,并且插件的创建者Igor Vaynberg说我误解了链接的问题,因为它们并不意味着select2将支持Zepto,它们只是意味着它将更容易支持。在将来的某个时间得到支持。

For Igor's answer see this comment . 有关Igor的答案,请参阅此评论 I might try and implement this myself, if my time permits it, and if I do I will edit this answer also. 如果时间允许,我可能会自己尝试实施此方法,如果可以,我还将编辑此答案。

如果要使用实际上支持Zepto.js的选择, 可能有兴趣尝试选择: https ://arendjr.github.io/selectivity/

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

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