Skip to content
Open
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
14 changes: 5 additions & 9 deletions autoform-select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,11 @@ Template.afSelect2.onRendered(function () {
}
});

var currentValues = $s.val();
if ((!currentValues && values.length > 0) ||
(currentValues && currentValues.toString() !== values.toString())) {
// select2 requires that we trigger change event
// for it to realize it needs to update the select2 list.
// We do it only if values have actually changed,
// which should help prevent autosave infinite looping.
$s.val(values).trigger('change');
}
// Using select2' "scoped change" event
// to avoid autosubmit when in an autosave form
// https://select2.org/programmatic-control/events#limiting-the-scope-of-the-change-event
$s.val(values).trigger('change.select2');

});
});

Expand Down