How to dynamically remove and add a component?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
18 views
There is a Date component, it is necessary to obtain the data. The knick on the button "-" delete the component, click "Add date" add it again. By clicking "Create event" generated object for sending it to the server.
I tried to show the work here.

What problems can't solve:
1. When you delete a component visually, everything is displayed correctly, but if you print the data that is not correct
2. Can't figure out how to push data into the array not only by clicking on the button "Add date", because now works so that the last added date is not pouchitsa in the array
by | 18 views

1 Answer

0 like 0 dislike
I tried to show the work here.

Looks very sad. Well, not a damn. So at this stage to help you will be very difficult - it is unclear where the problems manifest themselves, you are talking about (talking in General about anything would be more detail), and where shoals made by you when migrating the code to the sandbox.

Of the strange things that can be noted immediately:

1. Use date as key - can't have two events on one date? Well, the recreate component instance at each change of date too, somehow it looks dumb.

2. Data refresh (onDateInfo) - write data sent from a component at some unknown object, always the same (and the instances of the Date is still different). I do not understand, nonsense.

Slightly corrected your code - at the very least, adding/removing work, and the data is updated what is necessary (if I understood correctly). Now you can begin to tell you how to reproduce your problem - what to do where to look.
by

Related questions

0 like 0 dislike
1 answer
asked May 22, 2019 by webinar
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users