I am using Select2 to assign content to other users (multiple tags). It all works great except I can not find out how to remove assignees once added.
我正在使用Select2将内容分配给其他用户(多个标签)。这一切都很好,除了我不知道如何删除一旦添加的受让人。
Once I have added a user to the list of assignees in my modal, after I click the cross with class select2-search-choice-close
, the corresponding list item with class select2-search-choice
is deleted from the input field, but the id is not removed from assignee tokens (and is thus passed to the controller when I submit the form).
一旦我将用户添加到我的模态中的受理人列表中,在我单击带有select2-search-choice-close类的交叉后,将从输入字段中删除具有类select2-search-choice的相应列表项,但是id不会从受理人令牌中删除(因此在我提交表单时会传递给控制器)。
What am I missing?
我错过了什么?
NOTE: I am not 100% sure whether this is related, but I noticed that the assignee_ids passed when I submit the form sometimes contain the same id several times (e.g: assignee_ids => "12,1,4,4").
注意:我不是100%确定这是否相关,但我注意到,当我提交表单时传递的assignee_ids有时会多次包含相同的id(例如:assignee_ids =>“12,1,4,4”)。
This is how I initialize the input:
这是我初始化输入的方式:
$('#assignable_item_assignment_assignee_ids').select2({
minimumInputLength: 2
tags: true
tokenSeparators:[',', ' ']
createSearchChoice: (term, data) ->
{id: term, new_choice: true}
multiple: true
ajax:
url: url
dataType: 'json'
quietMillis: 150
data: (term, page) ->
query: term
results: (data, page) ->
return {results: data}
formatResult: userFormatResult
formatSelection: userFormatSelection
formatInputTooShort: (term, minLength) ->
"Search existing users or assign by email"
dropdownCssClass: 'select2'
})
And this is the form I am using:
这是我使用的形式:
<%= form_for AssignableItemAssignment.new, url: assignable_items_assignments_path, html: { class: "form-horizontal", id: "new-assignment" } do |f| -%>
<fieldset>
<div class="control-group">
<%= f.label :to %>
<div class="with-spinner">
<%= f.text_field :assignee_ids, placeholder: "Search users by name or email", class: 'select2' %>
</div>
</div>
<div class="control-group">
<%= f.label :add_a_message %>
<%= f.text_area :message, rows: 3, placeholder: "Add a message for your recipients (optional)" %>
</div>
<%= f.button "Submit", disable_with: 'Submiting' %>
</fieldset>
<% end %>
1 个解决方案
#1
0
I had a similar problem, which is fixed after installing latest release (3.3.2)
我有一个类似的问题,安装最新版本后修复(3.3.2)
#1
0
I had a similar problem, which is fixed after installing latest release (3.3.2)
我有一个类似的问题,安装最新版本后修复(3.3.2)