question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

modal component has a problem

See original GitHub issue

when 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>

image

first click

image

second click

image

third click

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mosinvecommented, Aug 26, 2017

Hi, check out this snippet please https://jsfiddle.net/cihkem/7xv8r3t7/. Is it fit your use case?

0reactions
alexsasharegancommented, Aug 26, 2017

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:

{
  computed: {
    modalShow: {
      get(){
        return this.$store.state.modalShow
      },
      set(show){
        this.$store.commit(UPDATE_MODAL_SHOW, Boolean(show))
      }
    }
  }
}
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found