use-bootstrap / use-bootstrap-select

Create a select element using the native Bootstrap 5 dropdown UI.
http://use-bootstrap-select.js.org/
MIT License
18 stars 3 forks source link

bootstrap is not defined #6

Closed kaelsantini closed 5 months ago

kaelsantini commented 6 months ago

I'm getting this error trying to instantiate this library.

import { Controller } from "@hotwired/stimulus"
import * as bootstrap from 'bootstrap';
window.bootstrap = bootstrap;
import { UseBootstrapSelect } from 'use-bootstrap-select'

export default class extends Controller {

  connect() {
    this.element.setAttribute('data-ub-select-search', true);
    this.element.setAttribute('data-ub-select-search-placeholder', 'Digite para buscar...');
    this.element.setAttribute('data-ub-select-no-results-text', 'Nenhum resultado encontrado.');

    this.select = UseBootstrapSelect(this.element);
  }
}

Without lines 2 and 3, I got the error:

image
erwinheldy commented 6 months ago

What is the response of console.log(typeof bootstrap) from your browser console?

erwinheldy commented 5 months ago

In v2, the library now works without bootstrap javascript.