
SelectItemView view that SelectItemView it. Next, the elements form a list, and the lists form what we need - the base BaseView . <script type="text/template" id="base-tempate"> <div class="primary"><!-- SelectView --></div> <div class="secondary"><!--  BaseView,   --></div> </script> .secondary will be recursively .secondary to the .secondary container, and when the active element .primary will clear the .secondary and render the new list.ItemModel model constructor:  initialize: function(){ if(this.get('items').length > 0){ this.set('label', this.get('label') + ' >'); } itemViews array of itemViews views that were rendered:  changeItem: function(){ u.each(this.itemViews, function(view){ if(view.el === this.el.options[this.el.selectedIndex]){ this.collection.selectedModel = view.model; this.collection.trigger('changeSelectedItem'); } }, this); }, changeSelectedItem signal that catches BaseView and tries to render a secondary list if there is a necessary collection:  renderSecondary: function(){ var collection = this.collection.selectedModel.itemsCollection; var container = this.$el.find('.secondary'); container.empty(); if(collection) (new BaseView({ collection: collection })).render().$el.appendTo(container); }  (function(j, b, u){ // j - jQuery // b - Backbone // u - Underscope })(jQuery.noConflict(), Backbone.noConflict(), _.noConflict());​ Source: https://habr.com/ru/post/148875/
All Articles