Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the content of a html.Div dynamically #13

Open
DrAkustik opened this issue Dec 19, 2024 · 3 comments
Open

Changing the content of a html.Div dynamically #13

DrAkustik opened this issue Dec 19, 2024 · 3 comments

Comments

@DrAkustik
Copy link

Is it possible to change the content of a "html.Div" dynamically?

Something like:

def load():
    with div_to_modify:
        html.P("Hello world!")

with html.Div():
    with vuetify.VBtn(
        click=(load, ""),
    ):
        vuetify.VIcon("mdi-plus-circle")

with html.Div() as div_to_modify:
    pass

I know that the code above does not work.

What I want to do is, load data after a button click and modify the content of another div based on the data. I think "v_if" and "v_show" are not appropriate for this functionality, because at the moment of starting the app I don't know the content of the data.

@DrAkustik
Copy link
Author

DrAkustik commented Dec 19, 2024

I found out that a vuetify component has an add_child method and it seems to possible to add components dynamically. However, the added components are not visible. Thus, I assume the parent component has to be updated or synchronized with the client.

What has to be done after using the add_child method to update the gui?

I remember that the vtk component has an update method. Is there something similar available for general vuetify components?

@jourdain
Copy link
Collaborator

jourdain commented Dec 19, 2024

Normally you rely on the templating infrastructure of Vue.js for handling the dynamic content of your page.

If you really have to modify it like you want, you just need to flush the layout. But in general that is a bad idea and they are better solutions like using another layout that you update while display as a child of the main one.

But without actual detail on what you really want to do, it is hard to advise.

@DrAkustik
Copy link
Author

Thanks. I will give the templating infrastructure a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants