v2.4.0
2.4 In Overview
The Marionette 2.4 release is primarily focused around adding power and performance to Marionette.CollectionView’s
and CompositeViews
. It is now possible for users to declaratively sort, filter, and reorder in a performant and clear way on the view layer. Prior to this work it was difficult and required significant workarounds.
As well as working on the CollectionView
layer we have added full support for lodash and multiple builds of backbone, underscore and lodash. Allowing the user to pick whatever tools they wish.
The other powerful feature that we introduced in this release is the concept of childEvents
for LayoutView
and their subviews. Prior to this release there was never a great way to listen or react to events that were triggered on subviews, like when something was rendered or destroyed. Now we have brought over the declarative childEvents
hash from CollectionView
into the LayoutView
.
As always come and join us in chat
View Some Live Demos
Features
- CollectionView
- You can now set a filter method on a
CollectionView
orCompositeView
to filter what views are shown. This is useful for when you are displaying a list that a user can filter. - Add the
reorderOnSort
option toCollectionView
andCompositeView
to use jQuery to move child nodes around without having to re-render the entire tree. This is a massive perf boost and is an easy win if you are sorting your collections. - The
CollectionView
now has aviewComparator
, to enable custom sorting on a per view basis regardless of what how your backing collection is sorted. - Refactor sort param lookup to use
Marionette.getOption
. - Fix childViews now fire a
before:show
event even if the childView is inserted after the parentCollectionView
orCompositeView
has been shown.
- You can now set a filter method on a
- Regions
- The
empty
method now takes an optionalpreventDestroy
flag to prevent the destruction of the view shown within. this.myRegion.empty({preventDestroy: true})
- The
- TemplateCache
- The templateCache
get
method now takes a second param of options to enable passing options to the loading of templates.
- The templateCache
- LayoutView
- Add a new helper method for easier showing of child nodes
showChildView
this.showChildView('sidebar', new SidebarView());
- Add a new helper method of easier retrieving of child nodes
getChildView
this.getChildView(‘sidebar’)
- Add a
destroyImmediate
option to theLayoutView
, to destroy the layout view element and then remove the child nodes. This is a perf optimization that you can now opt into. @ui
interpolation is now supported within region definitions on aLayoutView
- child event support was added via
onChildViewX
or via the declarativechildEvents
hash
- Add a new helper method for easier showing of child nodes
- ItemViews
- the
isRendered
property is now set totrue
after render, even if no template is set. - Views
- The
destroy
method now returns this instance that was destroyed to enable easier chaining of view actions. - If you define the options hash on your
Marionette.View
or if you pass options as a function to yourMarionette.View
, pass the result of options down to the backbone view constructor. - All views now have a
isRendered
property, that is updated afterrender
anddestroy
.
- the
- Object
- The
destroy
method now returns this instance that was destroyed to enable easier chaining of object actions.
- The
- Behavior
- The
destroy
method now returns this instance that was destroyed to enable easier chaining of behavior actions. - Expose the
UI
hash to a behavior instance. The behaviorUI
hash is a composite of the view hash and the behavior hash merged with the behavior hash tasking precedence.
- The
Util
Marionette._getValue
will now usecall
under the hood if no arguments are passed (micro optimization).- Add
Marionette.mergeOptions
toMarionette.View*
classes,Marionette.Object
.Marionette.AppRouter
,Marionette.Controller
mergeOptions
is a handy function to pluck certainoptions
and attach them directly to an instance.
Docs
- Minor documentation cleanups and fixes
Deprecation Notices
- Deprecate
Marionette.Controller
, UseMarionette.Object
instead.
Misc
- YAML api documentation is now linted on each PR.
- Add
Marionette.FEATURES
flag. - Refactor several methods to enable 100% compatibility with lodash.