mercredi 12 juillet 2017

EmberJs ctrl+click action without default context menu

I have a list of links in an Ember Js component template:

<a href="#" >Link</a>

and this is in my component.js file:

actions: {
    doSomething(){
        // ... action code
    },
}

Now, I would like to do alternative behavior in my action if the user is holding down the Ctrl key when they click one of the links.

I know how to detect the key being pressed in a 'keyDown' method but my problem is Chrome on my Mac displays a context menu with Ctrl+click.

So I add the following...

keyDown(event) {
   event.preventDefault();
}

but this also prevents the action.

Any ideas?




Aucun commentaire:

Enregistrer un commentaire