Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

childViewEvents not working when triggering from a child rendered in a region #3316

Closed
posti85 opened this issue Feb 15, 2017 · 3 comments
Closed

Comments

@posti85
Copy link

posti85 commented Feb 15, 2017

Actual behavior

I've done a simple example to ilustrate the issue: when the button b1 is pressed, the parent view doesn't listen the event (the 'button1Pressed' isn't shown in the console). However, when the button b2 is pressed, it does.

const LayoutView = Marionette.View.extend({

    template: _.template('<div class="region"></div>'),

    regions: {
        region: '.region'
    },

    childViewEvents: {
        button1Pressed: 'button1Pressed',
        button2Pressed: 'button2Pressed'
    },

    button1Pressed() {
        console.log('button1Pressed');
    },

    button2Pressed() {
        console.log('button2Pressed');
    }
});

const RegionView = Marionette.View.extend({

    template: _.template(
        `<button class="b1">Event</button>
         <button class="b2">Trigger</button>`),

    events: {
        'click .b1': 'button1Pressed'
    },

    triggers: {
        'click .b2': 'button2Pressed'
    },

    button1Pressed() {
        this.trigger('button1Pressed');
    }
});

const app = new Marionette.Application({
    region: '#main'
});

app.start();

var layoutView = new LayoutView();

var regionView = new RegionView();

app.showView(layoutView);

layoutView.showChildView('region', regionView);

Expected behavior

It should work the same way form button b1 and button b2.

Environment

  1. Marionette version: 3.0.1
  2. Backbone version: 1.3.3
  3. Additional build tools, etc:
@rafde rafde added the wontfix label Feb 15, 2017
@rafde
Copy link
Member

rafde commented Feb 15, 2017

That's intentional.
http://marionettejs.com/docs/master/marionette.view.html#view-triggers
@posti85 Why do you expect events and triggers to act the same way?

@paulfalgout
Copy link
Member

Actually the issue he's describing is that childViewEvents on a Layout doesn't work with trigger It does however work with triggerMethod, but that has been fixed for v3.2 here: #3247

@posti85
Copy link
Author

posti85 commented Feb 16, 2017

Yeah, that is! Thank you for the clarification and the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants