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.

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)

Deleted comment

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
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(