You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proposal: use a true Backbone collection for items in a component model.
Benefits include built-in change events and helper functions, and it also works to align with Adapt's existing parent > collection of children architecture.
Building on the excellent foundation from @lc-thomasberger, the functions have been whittled down to the below:
Component level itemsComponentModel.js
init(): custom initialise function to set up items and event listeners
setUpItems(): create a collection of ItemModels
getItem(index): get the item at specified index
getVisitedItems(): return all items where _isVisited: true
getActiveItems(): return all items where _isActive: true
getActiveItem(): return first item where _isActive: true
areAllItemsCompleted(): does what it says on the tin
checkCompletionStatus(): set component to complete if all items are completed (easily overriden)
reset(): resets all items and then component
resetActiveItems: set all items to _isActive: false
Item level itemModel.js
reset(): shortcut to set _isActive: false and _isVisited: false
toggleActive(isActive): shortcut to this.set('_isActive', ...);
toggleVisited(isVisited): shortcut to this.set('_isVisited', ...);
The text was updated successfully, but these errors were encountered:
Proposal: use a true Backbone collection for items in a component model.
Benefits include built-in change events and helper functions, and it also works to align with Adapt's existing parent > collection of children architecture.
Building on the excellent foundation from @lc-thomasberger, the functions have been whittled down to the below:
Component level
itemsComponentModel.js
init()
: custom initialise function to set up items and event listenerssetUpItems()
: create a collection ofItemModel
sgetItem(index)
: get the item at specified indexgetVisitedItems()
: return all items where_isVisited: true
getActiveItems()
: return all items where_isActive: true
getActiveItem()
: return first item where_isActive: true
areAllItemsCompleted()
: does what it says on the tincheckCompletionStatus()
: set component to complete if all items are completed (easily overriden)reset()
: resets all items and then componentresetActiveItems
: set all items to_isActive: false
Item level
itemModel.js
reset()
: shortcut to set_isActive: false
and_isVisited: false
toggleActive(isActive)
: shortcut tothis.set('_isActive', ...);
toggleVisited(isVisited)
: shortcut tothis.set('_isVisited', ...);
The text was updated successfully, but these errors were encountered: