mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-31 13:09:08 +01:00
Initialize Bootstrap in TypeScript
This commit is contained in:
parent
5612f8d2bd
commit
a00936f17e
2 changed files with 18 additions and 15 deletions
|
@ -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();
|
|
||||||
});
|
|
||||||
}
|
|
18
app/javascript/retrospring/initializers/bootstrap.ts
Normal file
18
app/javascript/retrospring/initializers/bootstrap.ts
Normal file
|
@ -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 a new issue