R
R
Roman Ogarkov2016-01-21 13:49:02
JavaScript
Roman Ogarkov, 2016-01-21 13:49:02

How to redraw a view in MarionetteJS?

Guys, tell me how to redraw the view when added to the collection

define([
  'marionettejs',
  'text!templates/tables/reports/reports-list.hbs',
  'collections/tables/reports-list',
  'db/reports-list'
  ], 
function (MarionetteJS, ReportsListTPL, ReportsListCollection, ReportsListDB) {
  'use strict';
  return Backbone.Marionette.ItemView.extend({
    template: _.template(ReportsListTPL),
    collection: new ReportsListCollection(ReportsListDB),
    tagName: 'ul',
    initialize: function () {
      this.collection.on('add', this.render)
    }
  });
})

Adding to the collection like this
App.reportsListView.collection.add({name: nameInput, id: data.id});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aen, 2016-01-21
@aen

ItemViewdoes not know how to keep track of the addition of elements to the collection. For such a case, it is better to use CollectionViewor CompositeView.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question