JavaScript Sample Request for Common Blazor Needs #27071
Labels
area-blazor
Includes: Blazor, Razor Components
enhancement
This issue represents an ask for new feature or an enhancement to an existing one
feature-blazor-wasm
This issue is related to and / or impacts Blazor WebAssembly
✔️ Resolution: Answered
Resolved because the question asked by the original author has been answered.
Status: Resolved
Milestone
Is your feature request related to a problem? Please describe.
We have been working on a Blazor server-side project and every once in a while despite our best efforts we have to fall back to javascript to solve some common problems. A great example of that is is to discover the browser size and get notifications of resizing so we can specifically modify markup as needed (when CSS is not enough). We have been using this nuget package https://github.com/EdCharbeneau/BlazorSize but I feel like this is a pretty common need. We can do quite a bit with CSS but sometimes we just really need to modify the markup ourselves depending on the screen size. Another example is just popping up a modal on the client. Currently we have a custom solution for doing that which relies on invoking a modal passing a class name of the modal I want to pop like so:
From the code behind:
await jSRuntime.InvokeVoidAsync("JSModal", ".price-grid-modal");
In the layout:
<script>
window.JSModal = (modalClass) => {
$(modalClass).modal();
}
</script>
I'm not sure if that is enough to give you an idea but there are a handful of things that developers really want/need that currently we need JavaScript for so more examples of those would be great.
Describe the solution you'd like
This may be just a great example for another article/blog entry. If you can just extend the JavaScript Interop examples for common types of tasks that the client does need to execute I think it would be very well received.
Additional context
The community is growing pretty strong around Blazor so there are some excellent nuget packages out there but due to lots of breaking changes over the last couple of years more examples from you would be very welcome. It's honestly an AWESOME stack and very few things are confusing about it but more practical examples would be great. Thank you!
The text was updated successfully, but these errors were encountered: