Skip to content

Commit

Permalink
Apply select2 to when new items are added in a form collection (Solid…
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup committed May 4, 2019
1 parent 1929f31 commit 5d215eb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/CoreBundle/Resources/public/js/util/form/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

define(
['jquery', 'marionette', 'lodash'],
['jquery', 'marionette', 'lodash', 'jquery.select2'],
function($, Mn, _) {
'use strict';

Expand Down Expand Up @@ -36,6 +36,13 @@ define(
collectionHolder.data('counter', ++counter);

var el = collectionHolder.append(form);

var select2 = $('select.select2');
if (select2.length) {
select2.select2({
theme: 'bootstrap'
});
}

this.$el.trigger('collection:add', el);

Expand Down

0 comments on commit 5d215eb

Please sign in to comment.