Closed HTMLGuyLLC closed 11 years ago
bump
Are you trying to attach a contextmenu on the body element? This is not
possible with the current implementation but you can add another div
element after the body and attach a contextmenu on that element.
James Santos Software/Web Applications Developer http://sydcanem.com
On Fri, Apr 5, 2013 at 12:42 PM, Shane Stebner notifications@github.comwrote:
bump
— Reply to this email directly or view it on GitHubhttps://github.com/sydcanem/bootstrap-contextmenu/issues/11#issuecomment-15938739 .
I'm trying to get it to not popup on the body's children. I experimented with this
$('body').on('contextmenu.context.data-api', toggle, function(e){ if($(e.target).is('body')){ ContextMenu.prototype.toggle }});
but it didn't work..Are you sure it's not possible with some variation of that?
Ok, I tested attaching it to the body
element and it worked. Just make
sure to add data-target={id of contextmenu}
attribute to the body
element.
James Santos Software/Web Applications Developer http://sydcanem.com
On Fri, Apr 5, 2013 at 10:16 PM, Shane Stebner notifications@github.comwrote:
I'm trying to get it to not popup on the body's children. I experimented with this
$('body').on('contextmenu.context.data-api', toggle, function(e){ if($(e.target).is('body')){ ContextMenu.prototype.toggle }});
but it didn't work..Are you sure it's not possible with some variation of that?
Shane Stebner 218-260-9198 shane@verswerks.com
Website Consultant & Developer Versatility Werks www.verswerks.com
This e-mail and any files transmitted with it may contain confidential and/or proprietary information and is protected from disclosure. It is intended solely for the use of the individual or entity who is the intended recipient. Unauthorized use of this information is prohibited. If you have received this in error, please contact the sender by replying to this message and delete this material from any system it may be on.
On Apr 5, 2013, at 8:20 AM, sydcanem notifications@github.com wrote:
Are you trying to attach a contextmenu on the body element? This is not possible with the current implementation but you can add another
div
element after the body and attach a contextmenu on that element.James Santos Software/Web Applications Developer http://sydcanem.com
On Fri, Apr 5, 2013 at 12:42 PM, Shane Stebner notifications@github.comwrote:
bump
— Reply to this email directly or view it on GitHub< https://github.com/sydcanem/bootstrap-contextmenu/issues/11#issuecomment-15938739>
.
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHubhttps://github.com/sydcanem/bootstrap-contextmenu/issues/11#issuecomment-15958026 .
Something like this https://gist.github.com/sydcanem/b8bf0831d5d1dfc9e005
James Santos Software/Web Applications Developer http://sydcanem.com
On Fri, Apr 5, 2013 at 10:23 PM, james santos icqhv.santos@gmail.comwrote:
Ok, I tested attaching it to the
body
element and it worked. Just make sure to adddata-target={id of contextmenu}
attribute to thebody
element.James Santos Software/Web Applications Developer http://sydcanem.com
On Fri, Apr 5, 2013 at 10:16 PM, Shane Stebner notifications@github.comwrote:
I'm trying to get it to not popup on the body's children. I experimented with this
$('body').on('contextmenu.context.data-api', toggle, function(e){ if($(e.target).is('body')){ ContextMenu.prototype.toggle }});
but it didn't work..Are you sure it's not possible with some variation of that?
Shane Stebner 218-260-9198 shane@verswerks.com
Website Consultant & Developer Versatility Werks www.verswerks.com
This e-mail and any files transmitted with it may contain confidential and/or proprietary information and is protected from disclosure. It is intended solely for the use of the individual or entity who is the intended recipient. Unauthorized use of this information is prohibited. If you have received this in error, please contact the sender by replying to this message and delete this material from any system it may be on.
On Apr 5, 2013, at 8:20 AM, sydcanem notifications@github.com wrote:
Are you trying to attach a contextmenu on the body element? This is not possible with the current implementation but you can add another
div
element after the body and attach a contextmenu on that element.James Santos Software/Web Applications Developer http://sydcanem.com
On Fri, Apr 5, 2013 at 12:42 PM, Shane Stebner < notifications@github.com>wrote:
bump
— Reply to this email directly or view it on GitHub< https://github.com/sydcanem/bootstrap-contextmenu/issues/11#issuecomment-15938739>
.
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHubhttps://github.com/sydcanem/bootstrap-contextmenu/issues/11#issuecomment-15958026 .
That's opening it everywhere (including it's children) you right click in body, not just on the background.
This worked
if($(e.target).is('section#content')){ //section#content was a replacement for body because it was already a wrapper, but now it won't popup if I click a child of section#content
if (!$contextmenu.length) {
var tp = getPosition(e, $this, $menu);
$menu.attr('style', '')
.css(tp)
.addClass('open');
$this.append($menu);
} else {
var tp = getPosition(e, $this, $menu);
$menu.attr('style', '')
.css(tp)
.toggleClass('open');
}
return false;
}
else{
return true;
}
}
You should add that feature for others, or atleast make this solution obvious. Basically you allow/deny the target and either return true to show the regular context menu, or show the special one.
I'm working on a new version for this plugin, maybe I will incorporate it on the next version. Thanks for the feedback.
No problem, thanks for trying to help and if you come up with a better solution, let me know!
I am in the process of rewriting the code I made 5 months ago, and I came up with this:
/* Context menu only when you click in #page_wrapper (not in it's children) */ $(document).bind("contextmenu", function(event){ if(event.toElement.id == 'page_wrapper'){ $("#contextMenu").css({"top": event.pageY + "px", "left": event.pageX + "px"}).show(); event.preventDefault(); } });
$(document).bind('click', function(){ $('#contextMenu').hide(); });
Just those few lines of code and it works great. I no longer use your plugin.
I'm hoping this is an easy fix, but I want it to only open when I click the body, not it's children. (it's for a quick background image changer)