Following an
bin/importmap pin pixabay-javascript-autocomplete
the importmap.rb
has the proper entry and the header of the page does have in the script tag for the imports
json block:
"pixabay-javascript-autocomplete": "https://ga.jspm.io/npm:pixabay-javascript-autocomplete@1.0.4/auto-complete.min.js",
application.js
was edited with alternately
import PixabayJavascriptAutocomplete from "pixabay-javascript-autocomplete"
import Autocomplete from "pixabay-javascript-autocomplete"
Yet, on the page where this needs to be fired, nothing happens.
If the script is entered in manually in the erb file, then the script fires as expected (accompanied by a second script which is dependent on the object being invoked)
<script>
// JavaScript autoComplete v1.0.4
// https://github.com/Pixabay/JavaScript-autoComplete
[...]
</script>
<%= javascript_tag do %>
var demo1 = new autoComplete({
selector: '#municipal',
minChars: 1,
source: function(term, suggest){
term = term.toLowerCase();
var choices = <%= raw @municipal_names %>;
var suggestions = [];
for (i=0;i<choices.length;i++)
if (~choices[i].toLowerCase().indexOf(term)) suggestions.push(choices[i]);
suggest(suggestions);
}
});
<% end %>
Thus, in practice, the pinned library is not being invoked properly.
How should this be done?