Modal not displaying when using router
See original GitHub issueI’m having an issue with my modal not displaying. I’ve attached a zip file with my code, but here’s the process I went through:
- I created a baseline project with
vue-cli
using the following command:
vue init webpack bootstraptest
Through the prompts, I answered Yes for using router, and no for everything else.
- Then I installed bootstrap and bootstrap-vue with
npm install --save bootstrap bootstrap-vue
- I added the following to the
main.js
file:
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
Vue.use(BootstrapVue)`
- I modified the Hello.vue file to look like such:
<template>
<div class="hello">
<h1>Modal Test</h1>
<b-btn @click="$root.$emit('show::modal', 'modal1')">Show Modal</b-btn>
<b-modal id="modal1" title="Submit your name">
<h3>Hello Modal</h3>
</b-modal>
</div>
</template>
<script>
export default {
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
Running this (while using the Chrome Vue dev tools) I can click the button and see the event being fired for the modal to display, but it’s not displaying. I tried the same process without using router and it seems to work fine.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
reactjs - React modal not displaying
Hi, In your file ModalItem.js you use different components in your render function that don't exist (Modal.Dialog, Modal.Header,...), change ...
Read more >Create contextual modal navigation with React Router V6.
When we click on the open-modal to open the modal, we do not want to show only the modal with a blank page...
Read more >ion-modal
ion-modal is a dialog that appears on top of mobile app content, and must be dismissed before interaction resumes. Learn more about custom...
Read more >Building a modal module for React with React-Router
Modals are very useful for displaying one view on top of another. ... Since this is not a react-router tutorial, I won't be...
Read more >MDB Angular Frame Modal not showing when using ...
You need to remove 2 outer divs from cookie-modal html (the first one should be the one with class 'modal-content, the rest will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I downloaded your code. Seems that you use Bootstrap 3 instead of supported 4 please install bootstrap as follows
npm install bootstrap@4.0.0-alpha.6
That’s bizzare because it worked with bootstrap 3 without using router i thought… oh well. Guess I can’t use this as my project breaks with bootstrap 4 in its current state