简体   繁体   English

select2和多个createSearchChoice

[英]select2 and multiple createSearchChoice

Is possible to use in select2 the createSearchChoice method to create 2 choices at the same time? 是否可以在select2中使用createSearchChoice方法同时创建2个选择? I'm creating an input form for tags, if the tag does not exists I need to create two choices at the same time: For example when the user types "missingtag" he needs to have two options 我正在为标签创建输入表单,如果标签不存在,则需要同时创建两个选项:例如,当用户键入“ missingtag”时,他需要两个选项

Create a public "missingtag" tag 创建一个公共的“ missingtag”标签
Create a private "missingtag" tag 创建一个私有的“ missingtag”标签

I can't see why you should not be able to create two tags at the same time. 我看不到为什么您不能同时创建两个标签。 This isnt testet and part of it is c/p from http://ivaynberg.github.io/select2/ . 这不是testet,一部分是来自http://ivaynberg.github.io/select2/的 c / p。

    $("#tags").select2({
        createSearchChoice: function(term) { 
          return { data: {
                  {id:'public-' + term, text:'public-' + term },
                  {id:'private-' + term, text:'private-' + term}
              }
          }
    });

我解决了修改js文件中的createSearchChoice函数的问题

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

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