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

View.triggers should include the DOM-Event #903

Closed
okitu opened this issue Feb 6, 2014 · 1 comment
Closed

View.triggers should include the DOM-Event #903

okitu opened this issue Feb 6, 2014 · 1 comment

Comments

@okitu
Copy link

okitu commented Feb 6, 2014

I'm working on a CompisiteView which displays a table, and the rows should be multi-selectable. The rows (ItemViews) have some triggers, which are catched, by the CompositeViews.itemEvents (#875 made this a lot smaller, thanks for this one!).

But here's my problem. I have no DOM-event in the handler anymore. Consider the example below:

var TableRow = Backbone.Marionette.ItemView.extend({
    triggers: {
        'click .select': 'click:select'
    }
});

var Table = Backbone.Marionette.CompositveView.extend({
    itemView: TableRow,

    itemEvents: {
        'click:select':'clickRowSelect'
    },

    clickRowSelect: function(eventName, args){
        // selection-code here
    }
});

Completely awesome what you can do in just a few lines of code.
Nevertheless, I have no DOM-event in clickRowSelect, so i can not check if the user uses ctrl, shift or alt to click on the rows, which i have to, to create a good selection ux.

By just adding the DOM-event to args i could do just that.
https://github.com/marionettejs/backbone.marionette/blob/master/src/marionette.view.js#L103

// build the args for the event
var args = {
    view: this,
    model: this.model,
    collection: this.collection,
    e: e
};

Of course, sometimes, there is no DOM-event, but then, also collectionis undefined most of the times.
I can't see a reason, why the event is omitted, but maybe there is one?

@cobbweb
Copy link
Member

cobbweb commented Feb 6, 2014

I think what you're asking for was requested in #441

@cobbweb cobbweb closed this as completed Feb 6, 2014
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

2 participants