Closed unclemopp closed 10 years ago
hi, I'm glad you find this plugin useful. Currently, the context menu is triggered by the browser 'contextmenu' event. Right now I don't have any idea on how to make it open on left clicks. If you find a solution please feel free to share it. Thanks. On May 18, 2013 4:57 PM, "unclemopp" notifications@github.com wrote:
I'm loving this context menu, but I can't figure out how to trigger it on a left mouse click. I figure someone has probably asked for/developed a solution for this, but I am unable to see it in the documentation/examples. Have I missed something?
— Reply to this email directly or view it on GitHubhttps://github.com/sydcanem/bootstrap-contextmenu/issues/24 .
Hi, i was working on this last week and solve this adding "click.context.data-api" to the $elements events list:
93 : .on('click.context.data-api contextmenu.context.data-api', $.proxy(this.show, this));
and
190: .on('click.context.data-api contextmenu.context.data-api', '[data-toggle=context]', function(e) {
this two changes work fine to me
This piece of code worked for me:
$( ... )
.on( 'click', function( e ) {
e.stopPropagation();
$(this).contextmenu( 'show', e );
} )
.contextmenu( { ... } );
Note the e.stopPropagation()
which is key here, because it stops line 95 from triggering:
$('html').on('click.context.data-api', $.proxy(this.closemenu, this));
@sydcanem Adding if (e.type==='click') e.stopPropagation();
to line ~65 would make the manual e.stopPropagation()
unnecessary. I'd recommend adding the left-click trigger snippet to the readme.md (because .contextmenu( 'show', e );
also requires the original event to be passed along). Thanks for the great plugin though, keep it up!
Hi Sayayin,
I did same as you did. And, it open context menu, but, It couldn't pick up table tr data value. Do you have any idea?
Thanks,
@mauvm awesome. seems to work. I have already noticed I had to use e.stopPropagation() before. Atleast it works :)
I'm loving this context menu, but I can't figure out how to trigger it on a left mouse click. I figure someone has probably asked for/developed a solution for this, but I am unable to see it in the documentation/examples. Have I missed something?