Reputation: 154
I need your help. I've been stuck with this problem for 2 days.
I'm building an application with electron (by Atom) and I use bootstrap-select. When I launch the app an error rises even if the function in question has not been called yet:
Uncaught TypeError: $(...).selectpicker is not a function
Do someone know how to fix that?
Upvotes: 0
Views: 621
Reputation: 21
For anyone get this error. The solution is use code in preload.js like snipet:
window.addEventListener("DOMContentLoaded", () => {
window.onload = async () => {
const $ = require('jquery')
require('bootstrap-select')
$("#your-select").selectpicker()
}
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../lib/bootstrap-select.min.css">
</head>
<body>
<select id="your-select" class="form-control selectpicker" data-live-search="true"></select>
<script src="../lib/bootstrap-select.min.js"></script>
</body>
</html>
Upvotes: 0
Reputation: 154
I solved my problem. It seems that using
require('bootstrap-select');
to include the library doesn't work properly, instead, I downloaded the bootstrap-select library and imported manually in the HTML file.
Upvotes: 0