Marionette bubble event from itemview to parent layoutview?

前端 未结 5 1656
面向向阳花
面向向阳花 2021-02-08 17:10

I have a layout view with a region, in that region I have a item view that triggers an event but it doesn\'t seem to be bubbled up to the layout view. Am I doing something wron

5条回答
  •  被撕碎了的回忆
    2021-02-08 18:00

    I'm not sure when this Marionette feature was introduced, but a much simpler solution would be using the childEvents hash: http://marionettejs.com/docs/v2.4.1/marionette.layoutview.html#layoutview-childevents

    ...
    childEvents: {
      "save:clicked" : "onSaveClicked"
    },
    ...
    

    You could also directly bind the child event to a function outside of LayoutView, if it makes more sense, like this:

    layout.on('childview:save:clicked', function(childView) {
      alert('clicked');
    }
    

提交回复
热议问题