Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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
<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.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

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


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(