将值添加到选定的多选 [英] Add values to a chosen multiselect

查看:77
本文介绍了将值添加到选定的多选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以动态添加新值到 selected.js 多选(类似于标记的工作原理)。

I am wondering whether it's possible to add new values on the fly to a chosen.js multiselect (similar to how tagging works).

我见过另一个 SO帖子用户说这是可能的。他链接到示例 fork ,但是我在实现这些方面遇到了一些困难。

I've seen in another SO post a user saying this is possible. He links to an example and a fork on github, but I've had some difficulties implementing those.

源代码是用CoffeeScript编写的。我已经尝试将它(使用在线编译器)编译为常规JavaScript,将代码粘贴到空白测试项目中,但是我遇到了错误。之后,我也加载了AbstractChosen和SelectParser(将它们编译为js)并且没有出现错误,但是动态添加项目功能不存在(尽管我初始化了上述链接)。

The source code is written in CoffeeScript. I've tried compiling it (using an online compiler) to regular JavaScript, copy pasted the code into a blank test project but I got errors. After that, I've loaded The AbstractChosen and SelectParser as well (compiled them to js) and didn't get errors, but the 'add items on the fly' functionality is not there (although i initialized the chosen described in the aforementioned link).

有有人用过这个叉子吗?如果是的话,请你分享一下你的经历吗?

Has anybody worked with this fork? If yes, could you please share your experiences with it?

推荐答案

你遇到的问题是因为你没有按照步骤在文档中:

The problem you have is because you haven't follow the steps in the documentation:

如果您下载了源代码,请安装正确的软件包,然后运行您选择的 selected.jquery.js 结束的构建命令。 proto.js chosen.css

If you download the source, install the correct packages and run the build commands you end with a chosen.jquery.js, chosen.proto.js and chosen.css.

所以以下步骤应该这样做为你:

So the following steps should do it for you:


  1. 下载: https://github.com/koenpunt/chosen/archive/option_adding.zip

  2. 安装包: npm install& ;&安培; gem install bundler&&捆绑安装

  3. 运行构建: grunt build (注意,为此你需要 grunt cli

  1. Download: https://github.com/koenpunt/chosen/archive/option_adding.zip
  2. Install packages: npm install && gem install bundler && bundle install
  3. Run build: grunt build (note, for this you'll need the grunt cli)

修改

为方便起见,下载已编译的版本

这篇关于将值添加到选定的多选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆