activeadmin-searchable_select 1.0.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +3 -2
- data/Appraisals +11 -5
- data/CHANGELOG.md +21 -3
- data/Gemfile +4 -0
- data/README.md +29 -3
- data/activeadmin-searchable_select.gemspec +2 -4
- data/app/assets/javascripts/active_admin/searchable_select.js +3 -0
- data/app/assets/javascripts/active_admin/searchable_select/init.js +46 -0
- data/gemfiles/rails_4.2_active_admin_1.0.0.pre4.gemfile +2 -0
- data/gemfiles/rails_5.1_active_admin_1.x.gemfile +9 -0
- data/gemfiles/{rails_5.1_active_admin_1.0.gemfile → rails_5.x_active_admin_1.x.gemfile} +2 -1
- data/gemfiles/{rails_5.1_active_admin_1.1.gemfile → rails_5.x_active_admin_2.x.gemfile} +3 -2
- data/lib/activeadmin/searchable_select/select_input_extension.rb +10 -10
- data/lib/activeadmin/searchable_select/version.rb +1 -1
- data/spec/features/end_to_end_spec.rb +32 -24
- data/spec/features/filter_input_spec.rb +50 -0
- data/spec/internal/app/assets/stylesheets/active_admin.scss +2 -0
- metadata +18 -11
- data/app/assets/javascripts/active_admin/searchable_select.js.coffee +0 -3
- data/app/assets/javascripts/active_admin/searchable_select/init.js.coffee +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0f06a7e42bdf09260f9581eb93b9b53254410068c9f0748d958621b75b47a1d9
|
4
|
+
data.tar.gz: 7a735aed9e7a2bd6da9c7702407a318dd0740f1b3d519bf220513163ddf848a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10cf476611bc7d46a2c39d8db812c1638de6d4484e6cd522962ab951a97ffb1353fc23313df5bf47cbb417176f0d3df9bb2de5557f5e7f33d650df4e27366bcb
|
7
|
+
data.tar.gz: 2bb155897e057ca7c073677cc232ccfdde3c761e463ee261382fed82f020921fa2b80e26a10dd8494650b21b0d1b0696934762a9f9e2d817d0f79a4bc9274dad
|
data/.travis.yml
CHANGED
@@ -10,7 +10,8 @@ cache:
|
|
10
10
|
|
11
11
|
gemfile:
|
12
12
|
- gemfiles/rails_4.2_active_admin_1.0.0.pre4.gemfile
|
13
|
-
- gemfiles/rails_5.1_active_admin_1.
|
14
|
-
- gemfiles/rails_5.
|
13
|
+
- gemfiles/rails_5.1_active_admin_1.x.gemfile
|
14
|
+
- gemfiles/rails_5.x_active_admin_1.x.gemfile
|
15
|
+
- gemfiles/rails_5.x_active_admin_2.x.gemfile
|
15
16
|
|
16
17
|
script: bundle exec rspec
|
data/Appraisals
CHANGED
@@ -2,14 +2,20 @@ appraise 'rails-4.2-active-admin-1.0.0.pre4' do
|
|
2
2
|
gem 'rails', '~> 4.2'
|
3
3
|
gem 'activeadmin', '1.0.0.pre4'
|
4
4
|
gem 'jquery-ui-rails', '~> 5.0'
|
5
|
+
gem 'sqlite3', '~> 1.3.6'
|
5
6
|
end
|
6
7
|
|
7
|
-
appraise 'rails-5.1-active-admin-1.
|
8
|
-
gem 'rails', '~> 5.1'
|
8
|
+
appraise 'rails-5.1-active-admin-1.x' do
|
9
|
+
gem 'rails', '~> 5.1.0'
|
9
10
|
gem 'activeadmin', '~> 1.0'
|
10
11
|
end
|
11
12
|
|
12
|
-
appraise 'rails-5.
|
13
|
-
gem 'rails', '~> 5.
|
14
|
-
gem 'activeadmin', '~> 1.
|
13
|
+
appraise 'rails-5.x-active-admin-1.x' do
|
14
|
+
gem 'rails', '~> 5.2'
|
15
|
+
gem 'activeadmin', '~> 1.0'
|
15
16
|
end
|
17
|
+
|
18
|
+
appraise 'rails-5.x-active-admin-2.x' do
|
19
|
+
gem 'rails', '~> 5.2'
|
20
|
+
gem 'activeadmin', '~> 2.0'
|
21
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,25 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
### Version 1.
|
3
|
+
### Version 1.2.1
|
4
4
|
|
5
|
-
|
5
|
+
2020-12-08
|
6
6
|
|
7
|
-
|
7
|
+
[Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/v1.2.0...v1.2.1)
|
8
|
+
|
9
|
+
- Fix ajax url when active admin namespace is set to false
|
10
|
+
([#22](https://github.com/codevise/activeadmin-searchable_select/pull/22))
|
11
|
+
|
12
|
+
### Version 1.2.0
|
13
|
+
|
14
|
+
2019-05-10
|
15
|
+
|
16
|
+
[Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-1-stable...v1.2.0)
|
17
|
+
|
18
|
+
- Add support for Active Admin 2.0
|
19
|
+
([#13](https://github.com/codevise/activeadmin-searchable_select/pull/13))
|
20
|
+
- Improve Appraisal setup
|
21
|
+
([#12](https://github.com/codevise/activeadmin-searchable_select/pull/12))
|
22
|
+
|
23
|
+
See
|
24
|
+
[1-1-stable branch](https://github.com/codevise/activeadmin-searchable_select/blob/1-1-stable/CHANGELOG.md)
|
25
|
+
for previous changes.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -23,8 +23,8 @@ Import stylesheets and require javascripts:
|
|
23
23
|
```
|
24
24
|
|
25
25
|
```coffee
|
26
|
-
|
27
|
-
|
26
|
+
// active_admin.js
|
27
|
+
//= require active_admin/searchable_select
|
28
28
|
```
|
29
29
|
|
30
30
|
## Usage
|
@@ -50,6 +50,15 @@ This also works for filters:
|
|
50
50
|
end
|
51
51
|
```
|
52
52
|
|
53
|
+
By default, you can only select one at a time for a filter. You can
|
54
|
+
specify a multi-select with:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
ActiveAdmin.register Product do
|
58
|
+
filter(:category, as: :searchable_select, multiple: true)
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
53
62
|
### Fetching Options via Ajax
|
54
63
|
|
55
64
|
For large collections, rendering the whole set of options can be to
|
@@ -138,7 +147,7 @@ based on the input attribute name, you can pass an object with a
|
|
138
147
|
end
|
139
148
|
```
|
140
149
|
|
141
|
-
####
|
150
|
+
#### Multiple Options Endpoints per Resource
|
142
151
|
|
143
152
|
A single ActiveAdmin resource can define multiple options endpoints:
|
144
153
|
|
@@ -167,6 +176,23 @@ To specify which collection to use, pass an object with a
|
|
167
176
|
end
|
168
177
|
```
|
169
178
|
|
179
|
+
#### Querying Multiple Attributes
|
180
|
+
|
181
|
+
ActiveAdmin Searchable Select querying is performed by Ransack. As such, you can
|
182
|
+
build your query in a way that it can query multiple attributes at once.
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
ActiveAdmin.register User do
|
186
|
+
searchable_select_options(scope: User.all,
|
187
|
+
text_attribute: :username,
|
188
|
+
filter: lambda do |term, scope|
|
189
|
+
scope.ransack(email_or_username_cont: term).result
|
190
|
+
end)
|
191
|
+
end
|
192
|
+
```
|
193
|
+
|
194
|
+
In this example, the `all` scope will query `email OR username`.
|
195
|
+
|
170
196
|
#### Passing Parameters
|
171
197
|
|
172
198
|
You can pass additional parameters to the options endpoint:
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
1
|
lib = File.expand_path('../lib', __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
require 'activeadmin/searchable_select/version'
|
@@ -22,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
22
20
|
spec.add_development_dependency 'rake'
|
23
21
|
spec.add_development_dependency 'appraisal', '~> 2.2'
|
24
22
|
spec.add_development_dependency 'rspec-rails', '~> 3.6'
|
25
|
-
spec.add_development_dependency 'combustion', '~>
|
23
|
+
spec.add_development_dependency 'combustion', '~> 1.0'
|
26
24
|
spec.add_development_dependency 'database_cleaner', '~> 1.6'
|
27
25
|
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
28
26
|
spec.add_development_dependency 'capybara', '~> 2.15'
|
@@ -31,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
31
29
|
spec.add_development_dependency 'semmy', '~> 1.0'
|
32
30
|
spec.add_development_dependency 'rails'
|
33
31
|
|
34
|
-
spec.add_runtime_dependency 'activeadmin', '
|
32
|
+
spec.add_runtime_dependency 'activeadmin', ['>= 1.x', '< 3']
|
35
33
|
spec.add_runtime_dependency 'jquery-rails', ['>= 3.0', '< 5']
|
36
34
|
spec.add_runtime_dependency 'select2-rails', '~> 4.0'
|
37
35
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
(function() {
|
2
|
+
function initSearchableSelects(inputs, extra) {
|
3
|
+
inputs.each(function() {
|
4
|
+
var item = $(this);
|
5
|
+
|
6
|
+
// reading from data allows <input data-searchable_select='{"tags": ['some']}'>
|
7
|
+
// to be passed to select2
|
8
|
+
var options = $.extend(extra || {}, item.data('searchableSelect'));
|
9
|
+
var url = item.data('ajaxUrl');
|
10
|
+
|
11
|
+
if (url) {
|
12
|
+
$.extend(options, {
|
13
|
+
ajax: {
|
14
|
+
url: url,
|
15
|
+
dataType: 'json',
|
16
|
+
|
17
|
+
data: function (params) {
|
18
|
+
return {
|
19
|
+
term: params.term,
|
20
|
+
page: pageParamWithBaseZero(params)
|
21
|
+
};
|
22
|
+
}
|
23
|
+
}
|
24
|
+
});
|
25
|
+
}
|
26
|
+
|
27
|
+
item.select2(options);
|
28
|
+
});
|
29
|
+
}
|
30
|
+
|
31
|
+
function pageParamWithBaseZero(params) {
|
32
|
+
return params.page ? params.page - 1 : undefined;
|
33
|
+
}
|
34
|
+
|
35
|
+
$(document).on('has_many_add:after', '.has_many_container', function(e, fieldset) {
|
36
|
+
initSearchableSelects(fieldset.find('.searchable-select-input'));
|
37
|
+
});
|
38
|
+
|
39
|
+
$(document).on('page:load turbolinks:load', function() {
|
40
|
+
initSearchableSelects($(".searchable-select-input"), {placeholder: ""});
|
41
|
+
});
|
42
|
+
|
43
|
+
$(function() {
|
44
|
+
initSearchableSelects($(".searchable-select-input"));
|
45
|
+
});
|
46
|
+
}());
|
@@ -45,7 +45,7 @@ module ActiveAdmin
|
|
45
45
|
|
46
46
|
def ajax_url
|
47
47
|
return unless options[:ajax]
|
48
|
-
template.polymorphic_path([
|
48
|
+
template.polymorphic_path([template.active_admin_namespace.route_prefix, ajax_resource_class],
|
49
49
|
action: option_collection.collection_action_name,
|
50
50
|
**ajax_params)
|
51
51
|
end
|
@@ -57,23 +57,23 @@ module ActiveAdmin
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def selected_value_collection
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def selected_value_option
|
64
|
-
option_for_record(selected_record) if selected_record
|
60
|
+
selected_records.collect { |s| option_for_record(s) }
|
65
61
|
end
|
66
62
|
|
67
63
|
def option_for_record(record)
|
68
64
|
[option_collection.display_text(record), record.id]
|
69
65
|
end
|
70
66
|
|
71
|
-
def
|
72
|
-
@
|
73
|
-
|
67
|
+
def selected_records
|
68
|
+
@selected_records ||=
|
69
|
+
if selected_values
|
70
|
+
option_collection_scope.where(id: selected_values)
|
71
|
+
else
|
72
|
+
[]
|
73
|
+
end
|
74
74
|
end
|
75
75
|
|
76
|
-
def
|
76
|
+
def selected_values
|
77
77
|
@object.send(input_name) if @object
|
78
78
|
end
|
79
79
|
|
@@ -24,35 +24,42 @@ RSpec.describe 'end to end', type: :feature, js: true do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe 'index page with searchable select filter' do
|
27
|
-
before(:each) do
|
28
|
-
music_category = Category.create(name: 'Music')
|
29
|
-
travel_category = Category.create(name: 'Travel')
|
30
|
-
|
31
|
-
Post.create(title: 'Best songs',
|
32
|
-
category: music_category)
|
33
|
-
Post.create(title: 'Best places',
|
34
|
-
category: travel_category)
|
35
|
-
end
|
36
|
-
|
37
27
|
it 'loads filter input options' do
|
28
|
+
Category.create(name: 'Music')
|
29
|
+
Category.create(name: 'Travel')
|
30
|
+
|
38
31
|
visit '/admin/posts'
|
39
32
|
|
40
33
|
expand_select_box
|
34
|
+
wait_for_ajax
|
41
35
|
|
42
36
|
expect(select_box_items).to eq(%w(Music Travel))
|
43
37
|
end
|
44
38
|
|
45
39
|
it 'allows filtering options by term' do
|
40
|
+
Category.create(name: 'Music')
|
41
|
+
Category.create(name: 'Travel')
|
42
|
+
|
46
43
|
visit '/admin/posts'
|
47
44
|
|
48
45
|
expand_select_box
|
49
|
-
|
50
|
-
wait_for_ajax
|
51
|
-
enter_search_term('T')
|
52
|
-
end
|
46
|
+
enter_search_term('T')
|
47
|
+
wait_for_ajax
|
53
48
|
|
54
49
|
expect(select_box_items).to eq(%w(Travel))
|
55
50
|
end
|
51
|
+
|
52
|
+
it 'loads more items when scrolling down' do
|
53
|
+
15.times { |i| Category.create(name: "Category #{i}") }
|
54
|
+
visit '/admin/posts'
|
55
|
+
|
56
|
+
expand_select_box
|
57
|
+
wait_for_ajax
|
58
|
+
scroll_select_box_list
|
59
|
+
wait_for_ajax
|
60
|
+
|
61
|
+
expect(select_box_items.size).to eq(15)
|
62
|
+
end
|
56
63
|
end
|
57
64
|
|
58
65
|
def expand_select_box
|
@@ -63,21 +70,22 @@ RSpec.describe 'end to end', type: :feature, js: true do
|
|
63
70
|
find('.select2-dropdown input').send_keys(term)
|
64
71
|
end
|
65
72
|
|
73
|
+
def scroll_select_box_list
|
74
|
+
page.execute_script '$(".select2-container ul").scrollTop(1000)'
|
75
|
+
end
|
76
|
+
|
66
77
|
def select_box_items
|
67
78
|
all('.select2-dropdown li').map(&:text)
|
68
79
|
end
|
69
80
|
|
70
|
-
def wait_for_ajax
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
yield
|
76
|
-
|
77
|
-
sleep(0.5) until finished_all_ajax_requests?(count)
|
81
|
+
def wait_for_ajax
|
82
|
+
Timeout.timeout(Capybara.default_max_wait_time) do
|
83
|
+
sleep 0.1
|
84
|
+
loop until finished_all_ajax_requests?
|
85
|
+
end
|
78
86
|
end
|
79
87
|
|
80
|
-
def finished_all_ajax_requests?
|
81
|
-
page.evaluate_script('
|
88
|
+
def finished_all_ajax_requests?
|
89
|
+
page.evaluate_script('jQuery.active').zero?
|
82
90
|
end
|
83
91
|
end
|
@@ -188,4 +188,54 @@ RSpec.describe 'filter input', type: :request do
|
|
188
188
|
text: 'Travel')
|
189
189
|
end
|
190
190
|
end
|
191
|
+
|
192
|
+
describe 'with the multiple option set to true' do
|
193
|
+
before(:each) do
|
194
|
+
ActiveAdminHelpers.setup do
|
195
|
+
ActiveAdmin.register(Category) do
|
196
|
+
searchable_select_options(scope: Category, text_attribute: :name)
|
197
|
+
end
|
198
|
+
|
199
|
+
ActiveAdmin.register(Post) do
|
200
|
+
filter(:category,
|
201
|
+
as: :searchable_select,
|
202
|
+
ajax: true,
|
203
|
+
multiple: true)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'renders select input with searchable-select-input css class and the multiple attribute' do
|
209
|
+
get '/admin/posts'
|
210
|
+
|
211
|
+
expect(response.body).to have_selector("select.searchable-select-input[multiple='multiple']")
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'does not render options statically' do
|
215
|
+
Category.create!(name: 'Travel')
|
216
|
+
|
217
|
+
get '/admin/posts'
|
218
|
+
|
219
|
+
expect(response.body).not_to have_selector('.searchable-select-input option',
|
220
|
+
text: 'Travel')
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'sets data-ajax-url attribute' do
|
224
|
+
get '/admin/posts'
|
225
|
+
|
226
|
+
expect(response.body).to have_selector('.searchable-select-input[data-ajax-url]')
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'renders the filter for multiple values selected' do
|
230
|
+
category1 = Category.create!(name: 'Travel')
|
231
|
+
category2 = Category.create!(name: 'Leisure')
|
232
|
+
|
233
|
+
get "/admin/posts?q[category_id_in][]=#{category1.id}&q[category_id_in][]=#{category2.id}"
|
234
|
+
|
235
|
+
expect(response.body).to have_selector('.searchable-select-input option[selected]',
|
236
|
+
text: 'Travel')
|
237
|
+
expect(response.body).to have_selector('.searchable-select-input option[selected]',
|
238
|
+
text: 'Leisure')
|
239
|
+
end
|
240
|
+
end
|
191
241
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin-searchable_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codevise Solutions Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: database_cleaner
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,16 +182,22 @@ dependencies:
|
|
182
182
|
name: activeadmin
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- - "
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: 1.x
|
188
|
+
- - "<"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '3'
|
188
191
|
type: :runtime
|
189
192
|
prerelease: false
|
190
193
|
version_requirements: !ruby/object:Gem::Requirement
|
191
194
|
requirements:
|
192
|
-
- - "
|
195
|
+
- - ">="
|
193
196
|
- !ruby/object:Gem::Version
|
194
197
|
version: 1.x
|
198
|
+
- - "<"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '3'
|
195
201
|
- !ruby/object:Gem::Dependency
|
196
202
|
name: jquery-rails
|
197
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,13 +250,14 @@ files:
|
|
244
250
|
- README.md
|
245
251
|
- Rakefile
|
246
252
|
- activeadmin-searchable_select.gemspec
|
247
|
-
- app/assets/javascripts/active_admin/searchable_select.js
|
248
|
-
- app/assets/javascripts/active_admin/searchable_select/init.js
|
253
|
+
- app/assets/javascripts/active_admin/searchable_select.js
|
254
|
+
- app/assets/javascripts/active_admin/searchable_select/init.js
|
249
255
|
- app/assets/stylesheets/active_admin/searchable_select.scss
|
250
256
|
- bin/rspec
|
251
257
|
- gemfiles/rails_4.2_active_admin_1.0.0.pre4.gemfile
|
252
|
-
- gemfiles/rails_5.1_active_admin_1.
|
253
|
-
- gemfiles/rails_5.
|
258
|
+
- gemfiles/rails_5.1_active_admin_1.x.gemfile
|
259
|
+
- gemfiles/rails_5.x_active_admin_1.x.gemfile
|
260
|
+
- gemfiles/rails_5.x_active_admin_2.x.gemfile
|
254
261
|
- lib/activeadmin-searchable_select.rb
|
255
262
|
- lib/activeadmin/inputs/filters/searchable_select_input.rb
|
256
263
|
- lib/activeadmin/inputs/searchable_select_input.rb
|
@@ -304,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
311
|
version: '0'
|
305
312
|
requirements: []
|
306
313
|
rubyforge_project:
|
307
|
-
rubygems_version: 2.
|
314
|
+
rubygems_version: 2.7.5
|
308
315
|
signing_key:
|
309
316
|
specification_version: 4
|
310
317
|
summary: Use searchable selects based on Select2 in Active Admin forms and filters.
|
@@ -1,29 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
initSearchableSelects = (inputs, extra = {}) ->
|
4
|
-
inputs.each ->
|
5
|
-
item = $(this)
|
6
|
-
# reading from data allows <input data-searchable_select='{"tags": ['some']}'>
|
7
|
-
# to be passed to select2
|
8
|
-
options = $.extend(extra, item.data('searchableSelect'))
|
9
|
-
url = item.data('ajaxUrl');
|
10
|
-
|
11
|
-
if url
|
12
|
-
$.extend(
|
13
|
-
options,
|
14
|
-
ajax: {
|
15
|
-
url: url,
|
16
|
-
dataType: 'json'
|
17
|
-
}
|
18
|
-
)
|
19
|
-
|
20
|
-
item.select2(options)
|
21
|
-
|
22
|
-
$(document).on 'has_many_add:after', '.has_many_container', (e, fieldset) ->
|
23
|
-
initSearchableSelects(fieldset.find('.searchable-select-input'))
|
24
|
-
|
25
|
-
$(document).on 'page:load turbolinks:load', ->
|
26
|
-
initSearchableSelects($(".searchable-select-input"), placeholder: "")
|
27
|
-
return
|
28
|
-
|
29
|
-
$(-> initSearchableSelects($(".searchable-select-input")))
|