How to bind to right mousebutton click in knockoutJs?
Asked Answered
C

1

11

I just can't get knockout to bind to the right mousebutton click with the event binding. Mouseover etc. are working fine.

Any suggestions?

Thanks Andreas

Clearcut answered 21/6, 2012 at 11:43 Comment(0)
C
38

Ok...

Right after writing down my question I did find out how to solve it.

But I thought maybe other people run into the same question, so I'll post question and answer at the same time:

You can bind to the right mouseclick by binding to contextmenu :

<tr data-bind="event: { contextmenu: viewModel.ContextMenuClick }">
Clearcut answered 21/6, 2012 at 11:43 Comment(4)
+1 Thanks, I am attempting to do the same thing. I've got the click event bound to a function, but how did you then generate the context menu?Labourer
is there an extra closing curly in there?Thickset
don't forget to accept your answer now that the appropriate time has expired. Especially since this is the first result on google for "knockout bind right click" :)Palaeography
Note: ContextMenuClick is the function you'll create within your knockout vm, and will likely rename. For example in my case: event: { contextmenu: handleRightClick }Bangka

© 2022 - 2024 — McMap. All rights reserved.