javascript - CompositeView not get "remove" event when extending the Backbone collection -


here steps:

  1. declare extended collection of backbone colleciton: extenedcollection = $.extend({}, backbonecollection, decorator);

  2. build composite view extended collection.

  3. do extenedcollection.remove(xmodel);

expected result: composite view catch remove event , remove relevant item view composite view.

actual result: backbone's remove() function fire "remove" event. marionette in _initialevents listening on "remove" event, not catch remove event when fired, , therfore not execute function "removeitemview".

comment: code extenedcollection = $.extend(backbonecollection, decorator); works fine. must create new object when extending original backbone collection.

help?

why not use built in backbone.collection.extend functionality? designed use case talking about.

// extend backbone types backbone.extend function var mycollectiontype = backbone.collection.extend(mydecorator);  var mycollection = new mycollectiontype(models); var mycompositeview = new myawesomecompositeview({collection : mycollection});  // not necessary. mycompositeview.onitemremoved = function () {   console.log(arguments); };  mycollection.remove(mymodel); // event handled composite view 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -