Replies: 2 comments 1 reply
-
Since this is a side project, I'm trying to keep things manageable and just keep everything asynchronous and in GitHub. I also assumed if there was a Discord channel I would be the only person ever in there!
My guess is that action events are not getting re-initialized when the child component re-renders. My example for child components (https://github.com/adamghill/django-unicorn/blob/bc721212561d03a5be34b3bf866146495161d955/example/www/templates/www/nested.html) only filters and edits existing pieces of data, so I will need to look into why this is happening. Sorry!
Once I fix the #168 bug and the event attachment issue I mentioned, I'll use your branch and see what I can fix up. The child component code is some of the most complicated in |
Beta Was this translation helpful? Give feedback.
-
I ended up on this page while trying to figure out how to dynamically add/remove child component to/from a parent. I am facing the same issue described by @Slawikus with the delete action doing nothing, except for the very first item. Any update? |
Beta Was this translation helpful? Give feedback.
-
Hi there! I haven't found a link to Slack or Discord channel where one can post questions regarding Django Unicorn, and filing GitHub Issues is also not the right place for questions and explanations. Hopefully, this is the right place.
I am trying to learn Unicorn and Todo list project is a good starting point. What I wanted to accomplish is to create todo, list todos and delete todo. I've put everything into one component and all works perfectly. Here is what I have:
Model:
Unicorn component:
And component template:
Now I though - great, time to extract some child components and I've started with extracting a component for adding new todos. No a big deal, here is a template for 'add-todo' component:
And unicorn component associated with it:
Component is hooked into the parent component via
and here when todo is added I am triggering the parent's component method to reload all todos. So far so good, all works just fine. Well, almost. When the new entry is added indeed it is shown in the list of all todos. But when I try to click "Delete" button on this newly added todo item nothing happens at all, no actions are triggered. But if I would refresh the page - all works just fine, and all items can be deleted including the newly created one.
Question is - what am I doing wrong?
And now the funny thing - if I would move the newly created AddTodo component into the bottom of the page, like so:
the behaviour changes:
a) If I would add only one single new todo item and click Delete action is triggered! But the list is not rerendered until I will start typing something in the add todo input field.
b) if I would add two or more todo items and Click delete - action is triggered on both of them and list is re-rendered.
I am totally confused :) and hope somebody can help me out to understand what is the problem and what is wrong with the way I am approaching it.
P.S. I have created a branch with the source code if one would like to check it out: https://github.com/Slawikus/django-unicorn-todo/tree/unicorny
Beta Was this translation helpful? Give feedback.
All reactions