@page "/"
@inject IJSRuntime jSRuntime;
<h1>Hello, world!</h1>
Welcome to your new app.
<div class="dropdown d-flex justify-content-center">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" @onclick="@(() => _loadContents = true)">
Dropdown button
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
@if (_loadContents){
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
}
</div>
</div>
@code {
private bool _loadContents { get; set; } = false;
protected override void OnAfterRender(bool firstRender){
if (!firstRender && _loadContents == true)
{
jSRuntime.InvokeVoidAsync("updateDropdownPosition");
}
}
}