H
H
HamSter2019-09-21 16:01:44
Vue.js
HamSter, 2019-09-21 16:01:44

How to add modal inside bootstrap-vue tag when opening bootstrap-vue?

I am using bootstrap-vue modal:
codesandbox:

<template>
  <b-button variant="link" class="btn-remove" @click="removeItemFromOrder(index)">
    Remove item
  </b-button>
</template>
<script>
export default {
  name: "HelloWorld",
  methods: {
    removeItemFromOrder: async function (position) {
        let self = this

        const h = this.$createElement

        const titleVNode = h('div', { domProps: { innerHTML: '<h2>Remove this item?</h2>' } })

        const messageVNode = h('div', { class: ['modal-complete'] }, [

          h('div', {
            domProps: {
              innerHTML:  '<h2>Remove this item?</h2>'+
                          '<span class="popup-meta">'+
                            'Are you sure you want to remove this item?'+
                          '</span>'
            }
          })
        ])


        this.$bvModal.msgBoxConfirm([messageVNode], {
          title: [],
          centered: true,
          modalClass: 'success-popup',
          hideHeader:true,
          footerClass: 'd-flex justify-content-center align-items-center',
          cancelVariant: 'outline-danger',
          okVariant: 'danger',
          okTitle: 'YES',
          cancelTitle: 'NO',
          ststic: false
        })
          .then(async function (result) {
            if (result) {
              self.currentOrder.items.splice(position, 1)
              await self.sync()
            }
          })
          .catch(err => {
            // An error occurred
          })
      },
  }
};
</script>

When a window is opened, it is added to the body.
Q: When opening a bootstrap-vue modal, how do I add it inside appor anywhere else in the template\tag ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-09-23
@Astatroth

Why create it? Bootstrap-vue has a modal component, add it to the component template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question