Hello ,
I used metronic 8.1.5 on Blazor Server and my problem is scripts.bundle.js not worked sometimes , I implement JS Import and anything after read docs but my problem still . this problem very important to me, because my development in middle and i can't change my template .
if i write details about my problem , when login into my project ( load layout ) sometime right menu working well and sometimes menu and top widget doesn't work ,when menu not working if i refresh page in browser this problem solved
my code in MainLayout.razor :
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender)
{
await JS.InvokeAsync<IJSObjectReference>("import", "/assets/js/scripts.bundle.js");
}
}
<script src="_framework/blazor.server.js" @*autostart="false"*@></script>
<script>
function setTheme(theme, isThemeDark) {
document.getElementsByTagName("body")[0].style.display = "none";
let synclink = document.getElementById("theme");
synclink.href = "_content/Syncfusion.Blazor.Themes/" + theme + ".css";
setTimeout(function () { document.getElementsByTagName("body")[0].style.display = "block"; }, 200);
}
</script>
<script>var hostUrl = "/assets/";</script>
<script src="/assets/plugins/global/plugins.bundle.js"></script>
<script src="/assets/js/scripts.bundle.js"></script>
<script src="/assets/js/Helper.js"></script>
<script src="/assets/plugins/custom/fullcalendar/fullcalendar.bundle.js"></script>
<script src="/assets/plugins/custom/datatables/datatables.bundle.js"></script>
<script src="/assets/js/widgets.bundle.js"></script>
<script src="/assets/js/custom/widgets.js"></script>
Nobody can't help me ? this problem is very important in my project
Hi,
Sorry for the late reply.
Please make sure that your component is wrapped with our initialization file Starterkit/Shared/MasterInit.razor.
Or you can call the component additional initialization on your layout file using the code below:
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender){
await JS.InvokeVoidAsync("KTComponents.init");
}
}
}