Initialize Bootstrap in TypeScript
This commit is contained in:
parent
5612f8d2bd
commit
a00936f17e
|
@ -1,15 +0,0 @@
|
|||
import 'bootstrap';
|
||||
import $ from 'jquery';
|
||||
|
||||
/**
|
||||
* This module sets up Bootstrap's JavaScript
|
||||
*
|
||||
* Inside of the exported function below, initialize Bootstrap
|
||||
* modules that require explicit initilization, like tooltips
|
||||
*/
|
||||
export default function (): void {
|
||||
$(document).ready(() => {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
$('.dropdown-toggle').dropdown();
|
||||
});
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
import * as Popper from '@popperjs/core';
|
||||
import * as bootstrap from 'bootstrap';
|
||||
|
||||
/**
|
||||
* This module sets up Bootstrap's JavaScript
|
||||
*
|
||||
* Inside of the exported function below, initialize Bootstrap
|
||||
* modules that require explicit initilization, like tooltips
|
||||
*/
|
||||
export default function (): void {
|
||||
document.addEventListener('turbo:load', () => {
|
||||
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
|
||||
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
|
||||
|
||||
const dropdownElementList = document.querySelectorAll('.dropdown-toggle');
|
||||
const dropdownList = [...dropdownElementList].map(dropdownToggleEl => new bootstrap.Dropdown(dropdownToggleEl));
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue