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

How to refresh a component from another component ? #730

Open
1 task done
CedricRaison opened this issue Aug 25, 2024 · 0 comments
Open
1 task done

How to refresh a component from another component ? #730

CedricRaison opened this issue Aug 25, 2024 · 0 comments

Comments

@CedricRaison
Copy link

CedricRaison commented Aug 25, 2024

I have a ListPostView component which list my posts.

class ListPostView(UnicornView):
    posts = []

    def mount(self):
        self.posts = list(Post.objects.all().order_by('-created_at'))

I have another component which is a form to create a new post.

I would like after saving a new post to refresh my ListPostView to display my new post.

class CreatePostView(UnicornView):
    content = ""

    def save(self):
        if self.content:
            post = Post.objects.create(content=self.content)
            self.content = ""
            # refresh ListPostView so it can show my new post.

Code of Conduct

  • I agree to follow this project's Code of Conduct
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

1 participant