-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to specify tokenSeparator? #87
Comments
hum, can see your html ? |
Hi, it is on Stackoverflow. There is no HTML, in ActiveAdmin the form is build in the model like so: # app/admin/model.rb
form do |f|
f.inputs do
f.input :keyword_list, as: :select2_tags
end
end So what I am trying to achieve is passing options to select2 on the line that says Any ideas? |
Ok, so after creating the formatsic input with f.input :keyword_list, as: :select2_tags, :input_html => { 'data-create-options' => "{tokenSeparators:[';']}" } I end up with the following HTML <input class="select2-input" data-create-options="{"width":"76%","tags":[...]}" data-create-options="{tokenSeparators:[';']}" id="item_keyword_list" name="item[keyword_list]" type="text" value="1 2 3; 1,2,3,Paul: Dokumente" /> As you can see, two |
Well, all my fault - haven't been working on this project for a while and forgot what I did back then (embarrasing). 😊 I am using a custom # app/inputs/select2_tags_input.rb
class Select2TagsInput < Formtastic::Inputs::StringInput
def input_html_options
default_options = { width: '76%', tags: ActsAsTaggableOn::Tag.all.map(&:name) }
create_options = options[:create_options] || {}
create_options.merge!(default_options)
data = { create_options: create_options }
super.merge(:class => 'select2-input', data: data)
end
end To specify custom create options, I do f.input :keyword_list, as: :select2_tags, :create_options => { :tokenSeparators => [";"] } which will now render correctly as <input class="select2-input" data-create-options="{"tokenSeparators":[";"],"width":"76%","tags":[...]}" id="item_keyword_list" name="item[keyword_list]" type="text" value="Federn, Paul: Dokumente" /> Select2 is still refusing to use ';' as a token separator, though, but that has nothing to do with select2-rails. Thanks anyways! |
Hello,
I am using select2-rails with ActiveAdmin to edit a list of tags backed by acts_as_taggable_on. How do I specify a value for tokenSeparator, as described in the docs for select2 AutoTokenization?
See also my question on Stackoverflow!
The text was updated successfully, but these errors were encountered: