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
<input class="form-control form-control-solid" id="myDatePicker" />
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.
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>
@code{
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if(firstRender){
await JS.InvokeVoidAsync("KTChartsWidget5.init");
}
}
}
init()
or alternative functions for initialization, you can use them to make instances of our js objects.