Conditionally Display a Button using Bootstrap-vue

Upon clicking the button labeled Launch centered modal, I anticipate that the modal will hide the buttons x,cancel, and ok due to the boolean value of showButton being set to false.

Subsequently, if I click on the show button, the buttons within the modal should appear since the value of showButton has been updated to true. How can this functionality be implemented?

https://i.sstatic.net/QzFgq.png

App.vue

<template>
  <div id="app">
    <b-button v-b-modal.modal-center>Launch centered modal</b-button>
    <b-modal id="modal-center" centered title="BootstrapVue">
      <p class="my-4">Vertically centered modal!</p>
      <button @click="setShowButton">Show Button</button>
    </b-modal>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      showButton: false,
    };
  },
  methods: {
    setShowButton() {
      this.showButton = true;
    },
  },
};
</script>

<style>
#app {
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

Codesandbox
https://codesandbox.io/s/flamboyant-herschel-62wpt?file=/src/App.vue:0-587

Answer №1

To customize the appearance of your modal, you can utilize the hide-header-close and hide-footer properties as outlined in the documentation available here.

<template>
  <div id="app">
    <b-button v-b-modal.modal-center>Launch centered modal</b-button>
    <b-modal
      id="modal-center"
      centered
      title="BootstrapVue"
      :hide-header-close="!this.showButton"
      :hide-footer="!this.showButton"
    >
      <p class="my-4">Vertically centered modal!</p>
      <button @click="setShowButton"gt;Show Button</button>
    </b-modal>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      showButton: false,
    };
  },
  methods: {
    setShowButton() {
      this.showButton = true;
    },
  },
};
</script>

<style>
#app {
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

For a working example, check out: https://codesandbox.io/s/hungry-architecture-zrcqj?file=/src/App.vue

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for importing a node module in React-Kotlin?

After creating my app using the create-react-kotlin-app command, it loaded successfully in Chrome. I then installed the React Material UI package via NPM without any issues. However, I am now facing the challenge of incorporating the Material UI module int ...

Is it possible to retrieve ALL current arrays in existence? If so, how can it be

I am working on a script and I need to fetch all existing arrays with their indexes as they are all used by the same function. Is it feasible to achieve this? The script I am working with is in shell script, but I am also curious to know if this can be do ...

Is it possible to include a component in an HTML file when the constructor of the component needs a parameter?

Recently delving into the world of AngularJs has been a captivating experience for me. I am aiming to develop a component with a constructor that accepts a parameter of type string. However, when I try to declare the selector on the HTML file, the componen ...

What is the best way to click on a particular button without activating every button on the page?

Struggling to create buttons labeled Add and Remove, as all the other buttons get triggered when I click on one. Here's the code snippet in question: function MyFruits() { const fruitsArray = [ 'banana', 'banana', & ...

Link components in Next.js now automatically add the current path when working with nested dynamic routes, making it

How can I effectively handle nested dynamic routes and utilize the Next.js Link component? Let's say I have 2 different file paths: /pages/projects/index.js <Link href={`/projects/${project.id}`} key={index}> <a>Project Name</a> ...

Different methods for adjusting CSS properties that are dependent on other components

I'm currently working on a website using the React library. While I have made progress, I am stuck on how to adjust CSS properties that are interdependent. Specifically, I need help removing the blur filter from my text area .mirror-container which is ...

Why is the text getting covered by the drop down menu?

I am currently working with bootstrap classes and I am facing an issue where the drop down menu is overlapping with the text. You can see the problem in the screenshot here: enter image description here <div class="collapse navbar-collapse" ...

What is the best way to apply styles to a React component that is passed as a prop?

I'm currently working on a component that is passed as a label prop. In order for me to utilize justify-content: space between within my div, I must ensure it has a width of 100%. You can see how this appears in the developer tools by clicking here. r ...

Creating multiple unique custom attributes for a specialized HTML element

Creating getter/setter methods for a custom attribute on a custom HTML element is quite simple: customElements.define('custom-el', class extends HTMLElement { static get observedAttributes() { return ['customAttr'] ...

Owl caroussel - Add a numbered image counter in between the navigation buttons

Recently, I made some adjustments to the owl caroussel nav buttons "next" and "previous" by modifying lines 2966 and 2968 to resemble arrows. To further enhance it, I now plan to include a div that will feature an image counter positioned between the navi ...

Issue encountered when attempting to update a specific element within an array using Mongoose

Looking to update a specific object within an array. { "_id": "543e2f8e769ac100008777d0", "createdDate": "2014-10-15 01:25 am", "cancle": false, "eventDateAndTime": "2014-02-12 12:55 am", "eventstatus": true, "userPhone": "44444444 ...

Transition from FadeOut to loading content and displaying it

Is there a way to simply display the content after loading without using fadeIn? $(function() { $('.hovers').click(function(event) { var target = $(this).attr('href'); window.location.hash = target; $.ajax({ url: ...

Using jQuery to send both the selected file contents and parameters in an ajax request

Currently, I am utilizing this code snippet to transmit the selected file's contents to the server: <!DOCTYPE html> <html lang="en> <head> <title>Test</title></head> <script src="https://ajax.googleapis.com/ ...

Embed a section of the webpage using an iframe

I am looking to feature a question from this website on another site using an iframe. However, I only want to display the question portion, not the entire page. <iframe src="http://qstn.mthmtcs.ir/index.php?qa=80" width="100%" height="100%" align="c ...

Exploring the relationship between Delphi and CSS in terms of the box model concept

I am currently working with a Delphi program on Windows to create HTML content. The challenge I am facing is achieving pixel-perfect WYSIWYG while dealing with text-wrap issues. When I generate the HTML from Delphi, the layout looks like this: -- ------- ...

How can you fix a navbar that won't stay in place?

I'm facing an issue with this example: When I scroll, the navbar moves along due to the fixed property, which affects the overall look. How can I make it disappear when scrolling, while keeping the logo intact? Can someone suggest if this layout is ...

Setting the axios baseURL configuration globally in Nuxt.js

When starting a new project, you can use the following command: npm init nuxt-app <project-name> To set up the baseURL for axios, refer to this guide: npm install @nuxtjs/axios In your nuxt.config.js file: modules: [ '@nuxtjs/axios' ...

What is the best way to allocate the remaining space to one div while setting the first div to 20vmin?

I am facing a challenge with two div elements in my design. One of the divs has been set to have a height of 20vmin, but I am struggling to make the other div take up the remaining height. Initially, I experimented with using 80vmin for the second div, ho ...

Using jQuery.ajax() with the POST method in a Grails application

I want to begin by expressing my gratitude for all of your valuable suggestions. I have encountered an issue with a jQuery ajax call in a Grails remote function call on the controller. The plugins currently installed in my project are jQueryUi - 1.10.3 and ...

Absorbing a mistake within my observable while also supplying a saved value - ensuring the subscription remains active

I'm really struggling with error handling in my observable and it's starting to drive me crazy. Despite reading countless articles, I still can't seem to get the hang of it. Ideally, I want to handle errors within the service itself and fall ...