I am displaying a travel itinerary (like one below) using a day model objects as part of Itinerary collection.
Day 1 5 Aug 2012 ‘Travel to SFO’
Day 2 6 Aug 2012 ‘Blah Blah’
Day 3 7 Aug 2012 ‘Blah Blah’
Day 4 8 Aug 2012 ‘Travel back home!’
Question:
- When I remove say Day 3 from above plan (this is not a issue), I want the Day 4 to be renamed as Day 3 and its date changed to 7th Aug instead of 8th Aug.
What is the best/backbone way to achieve it?
- When Day 3, is deleted, does it mean that Day 4’s index is now reduced by 1? or is the index to access Day 4 remains same?
Have a backbone collection "Days" with the model being "day". so when you delete a model. you refresh the views, which binds with the collection.
Yes, the Day 4’s index is reduced by one.
Edit-1
The Days collection has a function which binds to the delete function of its models.
This function calculates the indexes and the hashes.