Note that there are some explanatory texts on larger screens.

plurals
  1. POEvents bubling from child views doesn't work as expected
    primarykey
    data
    text
    <p>I would like to use the bubling behaviour of collection views but it doesn't seem to work.</p> <p>A bit of context: I display a modal <code>AddPartFromPurchase</code> that show a table populated with a collectionView. This works well.</p> <p>When the user clicks a row, the itemview triggers the <code>purchase:chosen</code> event so according to the documentation, I expect the collection view to receive the <code>itemview:purchase:chosen</code> event but no such event is ever triggered: neither in <code>AddPartFromPurchase</code> or <code>Purchases</code>. :(</p> <p>Here is the example code.</p> <pre> AddPartFromPurchase = Backbone.Marionette.ItemView.extend template: 'pages/vehicles/modifications/add_part_from_purchase' initialize: (attributes)-> @purchases = attributes.purchases onRender: -> view = new Purchases(el: @$('tbody'), collection: @purchases) @bindTo(view, 'all', @foo) view.render() foo: (event, foo, bar, baz)-> console.log(event, foo, bar, baz) Purchase = Backbone.Marionette.ItemView.extend template: 'pages/vehicles/modifications/purchase' tagName: 'tr' events: 'click' : 'selectPurchase' selectPurchase: -> @trigger('purchase:chosen', @model) false serializeData: -> purchase: @model part: @model.get('part') Purchases = Backbone.Marionette.CollectionView.extend itemView: Purchase initialize: -> @bindTo(@, 'all', @foo) foo: (event, foo, bar, baz)-> console.log(event, foo, bar, baz) </pre> <p>Maybe I'm doing it wrong, I feel bad about defining the listener in the <code>onRender</code>, but as I use a <code>el</code> I can't do that in <code>initialize</code>.</p> <p>How can I deal with that?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload