When you create a new row in the DOM, just give it a random string (via javascript). If the stripe moves up and down, make sure the key moves with it.
wire:key for local models
Hi all,
I'm developing an application where the user can create multiple models. However, these models should not be immediately saved to DB, but only when the user clicks on the 'save' button.
These models are heavily nested: a Page can have zero or more Stripes, which can have zero or more Blocks. Each component has 5-10 values that can be configured by the user.
When the user clicks a button, for example 'Add Stripe' button, a Stripe is added to the local collection of Page. When clicking on button 'Save', the Page model will store the local Stripe models in the database and update any models that already exist in the database.
I need to show these Stripes as list on the page. These Stripes can move up and down in the list using buttons. I'm currently having issues correctly displaying these, as I don't know what value of wire:key would be most fitting for the nonexistent models.
Thus my question: What value should I give to wire:key for models that are not yet saved in the DB?
Thank you for your help!
Please or to participate in this conversation.