dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.33k stars 9.97k forks source link

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

Open megafetis opened 10 months ago

megafetis commented 10 months ago

Is there an existing issue for this?

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
<div class="uk-modal-dialog uk-modal-body">
    <button class="uk-modal-close-default" type="button" uk-close></button>
    <div class="home-statement-form">
        <h3>title</h3>
        <form>
            <input type="text" class="uk-input" placeholder="Name" @bind="_val" />
            @_val
            <input type="text" class="uk-input" placeholder="Phone" />
            <input type="text" class="uk-input" placeholder="Text" />
            <button class="uk-button uk-button-primary uk-button-icon uk-button-block">
                Submit <ArrowRight />
            </button>
        </form>

    </div>
</div>
@code {
    string _val="";

  // ... INTERACTIVE CODE //

}
ghost commented 10 months ago

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

javiercn commented 10 months ago

@megafetis thanks for contacting us.

In general, the proposal sounds reasonable. It would be something like "extending JS root components to blazor web" with the addition of having to boot the runtime.

megafetis commented 10 months ago

@megafetis thanks for contacting us.

In general, the proposal sounds reasonable. It would be something like "extending JS root components to blazor web" with the addition of having to boot the runtime.

Yes, thankyou. It will be very useful for developing a static site with interactive widgets by demand, without need to reload parent page with @rendermode IteractiveServer

ghost commented 10 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.