V
V
voronin_denis2016-11-23 17:12:41
backbone.js
voronin_denis, 2016-11-23 17:12:41

How to nest one Marionette.ItemView within another?

There is a Marionette.CompositeView and a nested Marionette.ItemView. The Marionette.ItemView model has a nested array, which must also be displayed as a child (in the form of a tree or a table). How to organize this nesting? This frame is used for the first time.

var ItemView = Marionette.LayoutView.extend({
        tagName: 'tr',
        template: ItemTemplate,

        regions: {
            footer: "#content"
        },
        
        templateHelpers: function () {
            var model = this.model;
            var numberFunc = this.numberFormatter;
            var dateFunc = this.dateFormatter;
          

            return {
                USER_NAME: model.get('USER_NAME'),
                TMC_TYPE_NAME: model.get('TMC_TYPE_NAME'),
                DISMISS_COUNT: model.get('DISMISS_COUNT'),
                CULTURE_NAME:  model.get('CULTURE_NAME'),
                DATE: dateFunc(model.get('DATE')),
            };
        }
    });

 var ConfirmView = Marionette.CompositeView.extend({
        childView: ItemView,
        childViewContainer: "tbody",
        className: 'historyItem',
        emptyView: EmptyView,
        template: TemplateTable,
        
    });

    return ConfirmView;

<td> <div class ="tmcItem"><%= USER_NAME %></div></td>
<td ><div class ="tmcItem"><%= TMC_TYPE_NAME %></div></td>
<td ><div class ="tmcItem"><%= DISMISS_COUNT %></div></td>
<td ><div class ="tmcItem"><%= CULTURE_NAME %></div></td>
<td ><div class ="tmcItem"><%= DATE %></div></td>

As I understand it, you need to add layoutView.getRegion('content').show(new ItemView(), options). Just at what point?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Kayun, 2016-11-23
@voronin_denis

Are you apparently using Marionette v2?
Marionette.ItemView replace Marionette.LayoutView and render the collection to the region. In general, everything is detailed in the documentation and with examples marionettejs.com/docs/v2.4.7/marionette.layoutview...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question