Multiple 'on' events in ember.js

I am trying to make it possible to click on an element with both touch screens, and by clicking on the events touchStartand click.

How can I connect both of these events to the same Ember view?

I tried:

{{action "itsClicked" on="click touchMove"}}

{{action "itsClicked" on="click, touchMove"}}

{{action "itsClicked" on="click"}} {{action "itsClicked" on="touchMove"}}

+3
source share
2 answers

This is currently not supported. But there is an open issue about this, see # 569 in the GitHub tracker issue. You must add a comment.

A suggested solution to the GitHub problem is to use a custom view, something like this:

Ember.View.extend({
    click: function(evt) {
        this.fire('itsClicked', evt);
    },
    touchMove: function() {
        this.fire('itsClicked', evt);
    },
    itsClicked: function(e) {
        ...
    }
})
+6
source

Several actions are not supported - this forces you to separate your code by creating components (or views).

/ , :

App = Ember.Application.create({
    customEvents: {touchend: "click"}
});

, "click"

0

All Articles