Hey guys,
I have been trying to get select2 to work on Meteor for quite some time, but still no success. I tried the NPM package, then I switched to natestrauser:select2, then I experimented both - and neither of these options worked.
NPM-only: I get (…).select2( ) is not a function
natestrauser:select2-only: I don’t get an error, but select2 isn’t loaded anyway
Both together: Same thing as only natestrauser:select2
In all cases, the output is just a bootstrap select-box (the same thing I get without select2).
My code looks like this:
HTML
<div class="form-group mb-3">
<select id="select-tag" class="select2 form-control select2-multiple" data-toggle="select2"
multiple="multiple" data-placeholder="Choose ...">
<option value="AK">Alaska</option>
<option value="HI">Hawaii</option>
</select>
</div>
JS
Template.Tags.onRendered(function () {
$('[data-toggle="select2"]').select2();
});
I tried many different selectors for .select2( ). The id, the classes… nothing worked.
Any ideas?
Thanks!