Marionette.js. CollectionView's. emptyView

When a collection has no children, and you need to render a view other than the list of childViews, you can specify an `emptyView` attribute on your collection view. The `emptyView` just like the [`childView`](#collectionviews-childview) can also be passed as an option on instantiation or can be a function that returns the `emptyView`.

by marionettejs

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.radio/2.0.0/backbone.radio.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.marionette/3.0.0/backbone.marionette.js"></script>

JavaScript

const myCollection = new Backbone.Collection([]);

const MyEmptyView = Mn.View.extend({
  template: _.template('Nothing to display.')
});

const MyCollectionView = Mn.CollectionView.extend({
  collection: myCollection,
  emptyView: MyEmptyView
});

const myCollectionView = new MyCollectionView();

myCollectionView.render();

$('body').append(myCollectionView.$el);