dotnet / dotnet/aspnetcore

opportunity to add (load) root components via javascript when interactivity in current page is not enabled.

Open
#52,654 4 comments 0 reactions 0 assignees View on GitHub
area-blazor enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

_No response_

### Describe the solution you'd like

When i load a web site without interactivity, in some cases i want to init component in static page (home page) (for example: modal dialog) to use interactive mode on it. Currently i receive an error "Error: Dynamic root components have not been enabled in this application." To solve this problem i have to enable interactivity on the page on load. The idea: use static web site and call widgets with interactivity without reload page!

### Additional context

my case:
```
window.callModal = async function () {
var modalContainer = document.getElementById('modal-statement-form');
console.log(modalContainer);
await Blazor.rootComponents.add(modalContainer, 'modal-statement', {})
UIkit.modal(modalContainer).show();
}
```
component:
```
@rendermode InteractiveServer




title




@_val



Submit





@code {
string _val="";

// ... INTERACTIVE CODE //

}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.