Skip to content

Commit b8f43de

Browse files
authored
Merge pull request #1 from alexgreat70/select2-allow_clear
Select2 allow clear
2 parents 76765ce + 3bd7ca0 commit b8f43de

File tree

1 file changed

+9
-1
lines changed
  • app/assets/javascripts/active_admin/searchable_select

1 file changed

+9
-1
lines changed

app/assets/javascripts/active_admin/searchable_select/init.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
// reading from data allows <input data-searchable_select='{"tags": ['some']}'>
77
// to be passed to select2
88
var options = $.extend(extra || {}, item.data('searchableSelect'));
9+
10+
// default option allow clear (must have placeholder and allowClear to options)
11+
if (options.placeholder == undefined)
12+
options.placeholder = '';
13+
14+
if (options.allowClear == undefined)
15+
options.allowClear = true;
16+
917
var url = item.data('ajaxUrl');
1018

1119
if (url) {
@@ -43,4 +51,4 @@
4351
$(function() {
4452
initSearchableSelects($(".searchable-select-input"));
4553
});
46-
}());
54+
}());

0 commit comments

Comments
 (0)