Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4838

Handler for clicking the right button of the mouse

$
0
0

@polin11 wrote:

Hellow, how to write an event handler for the clicking the right mouse button
My example
template.hbs

`<button {{action "click_button"}} id='my_button'>Click and get result</button>`
Controller
    import Ember from 'ember';
    export default Ember.Component.extend({
        actions:{
    	     //tried doesn't work
            //the handler fires only after 2 clicks and number of keystrokes depends on the holding time
            click_button()
            {
              $('#my_button').mousedown(function(event){
                   event.preventDefault();
                   if(event.button == 0)
    		          console.log('Left button')
    	           if(event.button == 2)
                        console.log('Rigth button')
            });
            }
    	}
    )}

I saw the documentation https://guides.emberjs.com/v2.0.0/components/handling-events/ but could not understand.
I need a working example, thanks in advance

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4838

Trending Articles