Use ts-select2 in Rails with importmap

74 views Asked by At

I am trying to install ts-select2 in a Rails 7 App.

I ran:

./bin/importmap pin ts-select2

And it added this line to config/importmap.rb

pin "ts-select2", to: "https://ga.jspm.io/npm:[email protected]/dist/ts-select2.min.js"

My example in application.js

import 'ts-select2'

const select2 = new TsSelect2(document.getElementById('user_groups'), {minimumResultsForSearch: Infinity, width: `250px`});

Browser gives error:

Uncaught ReferenceError: TsSelect2 is not defined
0

There are 0 answers