简体   繁体   中英

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. According to this issue this pull request it should be possibel, yet I couldn't manage to do it. I usually get the error "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.
  • I also have the data component included into Zepto.
  • EDIT: Of course I have the select2 CSS included too. (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)
  • aliasing Zepto as 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.

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.

For Igor's answer see this comment . 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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