Updating an Item in a CollectionView

118 views
Skip to first unread message

Patrick Mulder

unread,
Oct 6, 2013, 1:12:38 PM10/6/13
to thor...@googlegroups.com
Hi,

I am trying to update an item in a CollectionView / http://thoraxjs.org/api.html#thorax.collection-view

But with:

define([
  'collection-view',
  'collections/genres',
  'templates/filter/genres',
  'templates/filter/item'
], function (CollectionView, Genres, template, item) {
  return CollectionView.extend({ 
    events: {
      'click a': 'toggleFilter' 
    },
    name: 'filter/genres',
    itemTemplate: item,
    template: template,
    toggleFilter: function(ev) {
      ev.preventDefault();
      var model = $(ev.target).model();
      console.log(model.get('name'));
      model.toggle();
    },
    initialize: function() {
      this.collection = new Genres();
      //this.listenTo(this.genres, "sync", this.render);
      this.collection.fetch();
      this.listenTo(this.collection, "change", this.render);
    }
  });
});

I only get one item to render, not the complete CollectionView.

Any clues where to look?

Thanks!

Patrick

Patrick Mulder

unread,
Oct 7, 2013, 2:15:53 AM10/7/13
to thor...@googlegroups.com
Using a view on the itemView attribute works:

], function (CollectionView, Genres, item, template) {
  return CollectionView.extend({ 
    name: 'filter/genres',
    itemView: item,
    template: template,
   //....


Reply all
Reply to author
Forward
0 new messages