Reputation: 35
npm install nouislider
in resources/js/bootstrap.js I added :
window.nouislider = require('nouislider');
I run the comand :
npm run dev
in public/js/script I added :
var slider = document.getElementById('slider');
noUiSlider.create(slider, {
start: [20, 80],
connect: true,
range: {
'min': 0,
'max': 100
}
});
5.and in my view I have :
<div class="col-md-12">
<div id="slider"></div>
</div>
I got this error :
Uncaught ReferenceError: noUiSlider is not defined
I don't know what I have to do after that ?
Upvotes: 1
Views: 1414
Reputation: 1138
This can be caused by a two errors:
Error 1
window.nouislider = require('nouislider');
Then to use it you do nouislider.create(...
and not noUiSlider.create(...
Error 2
The defer
attribute can also cause this (it's included by default with Laravel auth):
<script src="{{ asset('js/app.js') }}" defer></script>
You can either remove the attribute or execute your code once the page loads using window.onload()
Note
Also note that you need to add the nouislider
style sheet in your app.scss
add:
@import url("https://cdn.jsdelivr.net/npm/[email protected]/distribute/nouislider.min.css")
Upvotes: 3