Closed CristhianMotoche closed 7 years ago
That line is exactly what it indicates: it's a template. It's intended to be a "clean" row for JavaScript to clone from when you click on the 'add another item' type button. Note that the listItemTemplate element is supposed to be hidden from the user via CSS (if you use the itemAttrs
attribute splice, it adds style="display: none"
to just the template element).
The index value of -1
has no real meaning, it just has to be an integer. All that matters is that if you want to add a new item to the dynamic list, its index has to included in the associated 'indices' field (by default, -1
is not listed). If you really wanted, you could write your JavaScript to decrement new index values from 0 or follow the Fibonacci sequence (excluding the duplicate 1
value, of course) , rather than increment.
I only wanted to create a list not exactly a dynamic list. In my brief research I found this dynamic lists. However, they didn't satisfy what I wanted. So, I research a little bit more and create my own splices to solve my problem. Everything is fine now. Thanks for the explanation.
If you're creating your own splices, be aware that they won't be propagated via the dfSubView or dfInputList splices that come with digestive-functors because they're hard coded to only make digestive-functor's digestiveSplices splices available to its descendants. I've had to make quite a few custom splices for digestive-functors within my own projects.
I'd like to know why the dynamic listings start from -1. I'm pretty sure there must be a reason for this line: https://github.com/jaspervdj/digestive-functors/blob/master/digestive-functors-heist/src/Text/Digestive/Heist.hs#L476
Currently, using dynamic listings will produce an extra row that will start wil index (-1).