modal component has a problem
See original GitHub issuewhen I click the delete button in table and the modal is showed and the data is update,but When I click the same button cant show it then I close the modal and click again it’s worked ,why?
"bootstrap-vue": "^1.0.0-beta.5",
<template>
<div class="container contact-list-container">
<div class="row row-bottom">
<div class="col-auto">
<b-button variant="primary" @click="addContact">添加</b-button>
</div>
</div>
<div class="row">
<div class="col-12">
<b-table
striped
hover
bordered
show-empty
responsive
:items="contacts"
:fields="fields">
<template slot="actions" scope="row">
<b-btn size="sm" @click.stop="updateContact(row.item)" variant="success">编辑</b-btn>
<b-btn size="sm" @click.stop="showDeleteModal(row.item)" variant="danger">删除</b-btn>
</template>
</b-table>
</div>
</div>
<b-modal id="delModal"
ref="delModal"
title="提示"
ok-title="确定"
close-title="取消"
@ok="deleteContact">
<p>您确定要删除 “{{deleteModal.name}}“ 的基本信息吗?</p>
</b-modal>
</div>
</template>
<script>
import { mapState,mapActions } from 'vuex'
export default {
data() {
return{
deleteModal:{
id:0,
name:''
},
fields: {
index:{label:'#'},
fullName: { label: '姓名'},
email: { label: '邮箱' },
description: { label: '简介' },
actions: { label: '操作',class:'text-center' }
},
sortBy: null,
sortDesc: false,
filter: null,
modalDetails: { index:'', data:'' }
}
},
computed:{
...mapState({
contacts:state=>state.ContactList.contacts
})
},
created(){
this.getContacts();
},
methods: {
...mapActions([
'getContacts',
'deleteContactById'
]),
showDeleteModal(contact){
this.deleteModal.id=contact.id;
this.deleteModal.name=`${contact.first_name}${contact.last_name}`
this.$refs.delModal.show();
},
addContact(){
this.$router.push('/contactsManage/addContact')
},
updateContact(item){
console.log('item:')
console.log(item)
this.$router.push(`/contactsManage/editContact/${item.id}`)
},
deleteContact(){
this.$refs.delModal.hide();
this.deleteContactById({
id:this.deleteModal.id,
success:()=>{
this.getContacts();
}
})
}
}
}
</script>
<style lang="less">
#delModal{
.modal-dialog {
top:100px;
}
}
.contact-list-container{
.row-bottom{
margin-bottom:15px;
}
}
</style>
first click
second click
third click
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Modal Component and props not working properly
You are trying to render an object on your modal component, and React can't render objects. What you should change is: <h2> {props....
Read more >Calling modal in component from another component
Hi, We are trying to open a modal in a component(navbar) from within another component(Inbox) When clicking link in navbar (click)=inbox.show() inbox modal...
Read more >Use React component as a modal - App Platform
I had a problem using this solution, sometimes the function app.initialized() do not reach the resolve and the modal window stay showing the ......
Read more >Modal - Bootstrap
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >React Modal component - Material UI - MUI
The term "modal" is sometimes used to mean "dialog", but this is a misnomer. A modal window describes parts of a UI. An...
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
Hi, check out this snippet please https://jsfiddle.net/cihkem/7xv8r3t7/. Is it fit your use case?
What do you mean by Vuex state triggers? If you need Vuex state to control v-model, you can use a two way computed property: