Blazor - Date Pickler, modals etc.
Hi.
I'm trying to figure out how to do some of the JS stuff with blazor. Are there any easy predefined functionality for this? Can't find it in the docs.
As an example I want to make a field a datepicker, but it
The HTML
The JS Invoking (
await JS.InvokeVoidAsync("showDatepicker", "myDatePicker");
The JS
window.showDatepicker = (id) => {
$("#" + id).daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minYear: 2022
});
};
The JS is called - verified by alert popup for testing.
Replies (1)
Hi Ulrik,
Firstly you need to include a js file for your view.
<script suppress-error="BL9992" src='@KTTheme.getAssetPath("plugins/custom/datatables/datatables.bundle.js")'></script>
Then you can trigger the global functions of this file in the OnAfterRenderAsync method.
@code{
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender){
await JS.InvokeVoidAsync("KTChartsWidget5.init");
}
}
}
All our custom js files should have init()
or alternative functions for initialization, you can use them to make instances of our js objects.
Regards,
Lauris Stepanovs,
Keenthemes Support Team