Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable modal-ok slot of b-modal in vue bootstrap?

I have used modal-ok slot available in b-modal slots to render the OK button of b-modal. I want to conditionally disable the OK button. I have tried 2 methods with no luck. Any suggestion is welcome on how to disable the OK button rendered using the slot.

  1. Disabled prop

     <div
        slot="modal-ok"
        :disabled="true"
        @click.stop="uploadFile(item.id)"
      >
        Upload
      </div>
    
  2. ok-disabled prop of b-modal

      <div
        slot="modal-ok"
        :ok-disabled="true"
        @click.stop="uploadFile(item.id)"
      >
        Upload
      </div>
    
like image 892
Don D Avatar asked May 21 '20 12:05

Don D


People also ask

How do I close b modal Vue?

<b-modal> supports close on ESC (enabled by default), close on backdrop click (enabled by default), and the X close button in the header (enabled by default).

How do I turn off bootstrap5 modal?

There are few ways to close modal in Bootstrap: click on a backdrop, close icon, or close button. You can also use JavaScript hide method. Click the button to launch the modal. Then click on the backdrop, close icon or close button to close the modal.

How do you prevent bootstrap Vue modal from closing when clicking outside?

By default, dialog can be closed by pressing Esc key and clicking the close icon on the right of dialog header. It can also be closed by clicking outside of the dialog using hide method. Set the closeOnEscape property value to false to prevent closing of the dialog when pressing Esc key.

How do I close modal after submitting Vue?

To close a modal using vue. js you can use the click event i.e. @click to trigger change in modal visibility. So, whenever the close button is pressed the @click method will trigger the function associated with the action ( here, hiding the modal ).


2 Answers

Use the ok-disabled prop on <b-modal>, to conditionally enable/disable the ok button.

<b-modal :ok-disabled="true">
  <!-- Content -->
</b-modal>

For more information check out this section of the documentation.

like image 140
Hiws Avatar answered Sep 28 '22 09:09

Hiws


Just add hide-footer if you want to get rid of the buttons

<b-modal hide-footer>
  <!-- Content -->
</b-modal>
like image 38
Mihai Avatar answered Sep 28 '22 10:09

Mihai