sa-si-dev / virtual-select

A javascript plugin for dropdown with virtual scroll
https://sa-si-dev.github.io/virtual-select
MIT License
250 stars 58 forks source link

VirtualSelect is not defined #140

Closed warmwhisky closed 2 years ago

warmwhisky commented 2 years ago

I have followed the Getting Started instructions

<link rel="stylesheet" href="path/to/virtual-select.min.css">

<script src="path/to/virtual-select.min.js">

And

<div id="sample-select"></div>

VirtualSelect.init({
  ele: '#sample-select',
  options: [
    { label: 'Options 1', value: '1' },
    { label: 'Options 2', value: '2' },
    { label: 'Options 3', value: '3' },
  ],
});

I continue to get the VirtualSelect is not defined error

I am compiling with Laravel Mix and can confirm both virtual-select.css and virtual-select.js files are in my app.css and app.js

// where exactly should this code go?
// I have it under app.js like so

<script>
VirtualSelect.init({
  ele: '#sample-select',
  options: [
    { label: 'Options 1', value: '1' },
    { label: 'Options 2', value: '2' },
    { label: 'Options 3', value: '3' },
  ],
});
</script>
warmwhisky commented 2 years ago

Literally 10 seconds after I posting this I realised my app.js file was in the head with the defer attribute. I placed it below the content near the closing body tag and hey presto it worked :p