I would like to be able to hide and show the itemViewContainer, but I feel it can be done better.
Here is my code:
MyCompView = Backbone.Marionette.CompositeView.extend({ // ITEM VIEW itemView: MyView, // ITEM VIEW CONTAINER itemViewContainer: 'tbody', // EVENTS events: { 'click #table-toggle': 'onToggleClick' }, onToggleClick: function(event){ event.preventDefault(); this.toggle(); }, // Toggle toggle: function(){ this.$(this.itemViewContainer).toggle(); }
Here is the template for MyCompView
<script id='MyCompView-template' type='text/x-handlebars-template'> <div> <span id='heading-container' style="font-weight:bold">Some name</span> <a id='table-toggle' href="#">[-]</a> </div> <table> <thead> </thead> <tbody> </tbody> </table>
user1473339
source share