@q8xbox check how to open bootstrap 5 modals manually https://getbootstrap.com/docs/5.0/components/modal/#show
Jun 27, 2022
8
Level 1
Bootstrap Modal does not work display
I'm trying to use Bootstrap Modal to add, edit & remove categories but the only Modal display is addCategoryModal where both editCategoryModal & removeCategoryModal does not display at all so I want to understand about this why it does not work...
This is my code: https://codeshare.io/qPqqwM
Level 73
@Q8Xbox I would use the KISS method and do something like this
html
<div id="modal1" class="is-hidden">1</div>
<div id="modal2" class="is-hidden">2</div>
<div id="modal3" class="is-hidden">3</div>
<button onclick="showModal('modal1')"> open 1</button>
<button onclick="showModal('modal2')"> open 2</button>
<button onclick="showModal('modal3')"> open 3</button>
css
.is-hidden {
display:none;
}
js
function showModal(e) {
let el = document.querySelector('#' + e);
el.classList.remove('is-hidden');
}
1 like
Please or to participate in this conversation.