chanan / BlazorStrap

Bootstrap 4 Components for Blazor Framework
https://blazorstrap.io
The Unlicense
920 stars 157 forks source link

How do I call Toggle for a modal? #601

Open coolblue2000 opened 1 year ago

coolblue2000 commented 1 year ago

How do I call toggle on a modal?

For instance I have the following

<BSModal DataId="modal1">
    <MyComponent></MyComponent>
    </BSModal>

@code{
   public async Task Show()
   {
         //toggle modal1
   }
}

I want to do some processing in Show() and set some parameters in MyComponent etc then show the modal. All the examples simply trigger the modal from a button click.

jbomhold3 commented 1 year ago
<BSModal DataId="modal1" @ref="modal">
    <MyComponent></MyComponent>
</BSModal>
@code{
private BSModal modal; 
   public async Task Show()
   {
        modal.ShowAsync();
   }
}
coolblue2000 commented 1 year ago

Thanks that is great!

SydoxX commented 1 year ago

While this is still open; this would be a great example to be added to the docs :)