Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Fix problems with latest jquery #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/assets/javascripts/active_admin/select2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= require select2

//= require_tree ./select2
3 changes: 0 additions & 3 deletions app/assets/javascripts/active_admin/select2.js.coffee

This file was deleted.

30 changes: 30 additions & 0 deletions app/assets/javascripts/active_admin/select2/select2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';
var initSelect2;

initSelect2 = function(inputs, extra = {}) {
return inputs.each(function() {
var item, options;
item = $(this);
// reading from data allows <input data-select2='{"tags": ['some']}'> to be passed to select2
options = $.extend({
allowClear: true
}, extra, item.data('select2'));
// because select2 reads from input.data to check if it is select2 already
item.data('select2', null);
return item.select2(options);
});
};

$(document).on('has_many_add:after', '.has_many_container', function(e, fieldset) {
return initSelect2(fieldset.find('.select2-input'));
});

$(document).on('page:change page:load turbolinks:load', function() {
initSelect2($(".select2-input"), { placeholder: ""
});
});

$(document).ready(function() {
initSelect2($(".select2-input"), { placeholder: "" });
});

17 changes: 0 additions & 17 deletions app/assets/javascripts/active_admin/select2/select2.js.coffee

This file was deleted.