Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to dynamically add DOM elements with Blazor?

$
0
0

I have a chat-like Blazor application that I need to continuously add DOM elements to:

<EditForm model="this" OnValidSubmit="@Query"><div id="qrContainer"><div><input type="text" @ref="queryElement" @bind="query" /></div><div><div id="output" @bind="response"></div></div></div></EditForm>@code {    private String query { get; set; } = null;    private String response { get; set; }    private ElementReference queryElement;    private async Task Query(){        // ...            var responseString = await responseService.getResponseAsync(query);            // Need to add DOM element to "output" here.        // ...    }}

From what I understand, JSInterop is not the preferred way to do this. So, how do I add new DOM elements the "Blazor" way?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>