1
votes

I'm trying to make in-row editing in Marionette application. What is the best approach to do this?

I have table which is Marionette.CompositeView and rows of this table are Marionettes ItemViews. Now I'm trying to change clicked table row (ItemView) to a CompositeView which will contain inputs and selects with ajax fetched data. Is this a good approach?

1

1 Answers

2
votes

You can use CollectionView.getChildView to render different view for edited items, but this can cause performance problems if you need to render large collections.

I modified Derick Bailey's Tree View example to show how this can be done - http://jsfiddle.net/msamujlo/8g3abfg2/

// The recursive tree view
var TreeView = Backbone.Marionette.CompositeView.extend({
    template: "#node-template",
    tagName: "ul",
    getChildView: function(item){
        return item.get('isEditable')? EditorView : TreeView;       
    },
    // ... more methods
};
var EditorView = TreeView.extend({
    template: "#editor-template",
});

...