Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For Marionette <strong>>= 2.0</strong>, <code>CollectionView</code> and <code>CompositeView</code> <a href="https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.collectionview.md#marionettecollectionview" rel="noreferrer">maintain sorting by default</a>.</p> <p>For Marionette <strong>&lt; 2.0 and >= 1.3.0</strong>:</p> <pre><code>var MySortedView = Backbone.Marionette.CollectionView.extend({ // ... appendHtml: function(collectionView, itemView, index) { // Already sorted when buffering. if (collectionView.isBuffering) { Backbone.Marionette.CollectionView.prototype.appendHtml.apply(this, arguments); } else { var childrenContainer = $(collectionView.childrenContainer || collectionView.el); var children = childrenContainer.children(); if (children.size() === index) { childrenContainer.append(itemView.el); } else { childrenContainer.children().eq(index).before(itemView.el); } } } }); </code></pre> <p>For Marionette <strong>&lt; 2.0 or &lt; 1.3.0</strong> (same as before without buffering):</p> <pre><code>var MySortedView = Backbone.Marionette.CollectionView.extend({ // ... appendHtml: function(collectionView, itemView, index) { var childrenContainer = $(collectionView.childrenContainer || collectionView.el); var children = childrenContainer.children(); if (children.size() === index) { childrenContainer.append(itemView.el); } else { childrenContainer.children().eq(index).before(itemView.el); } } }); </code></pre> <p>It's the same for CollectionView and CompositeView.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload