tags:

views:

34

answers:

1

Hi! I have one page filled with images (image1, image2, image3). What I would like to happen is:

While a right-click is active on image1... image2 and image2 are disabled to receive any left-clicks or right-clicks until I end the right-click on image1. Does anyone know how to achieve this in javascript? Thank you!

A: 

Here is possible solution if you are using jQuery.

  1. Get the plugin from http://abeautifulsite.net/blog/2008/05/jquery-right-click-plugin/
  2. You code will be something like:

    $(document).ready( function() {
    
    
    
    // Capture right click
    $("#imgX").rightClick( function(e) {
    
    
        $('body').click(function () {
            return false;
        });
    
    
    });
    
    });

Actually above wont work. Is your right click menu custom or browser default? If it is custom then you can use the above as guidelines on how to do it. Not sure what you are trying to achieve. Normally, when you right click on an image, and the context menu is active, if you click on something else, the context menu disappears so technically, what you want is already being achieved.

Alec Smart
Hi Alec, I'm using the jquery notes plugin (http://bit.ly/a8Mv8L). Basically it's a plugin that allows you to put notes on an image. The problem arises is when I have many images on one page. To edit a note, I right-click on it. However, during an edit, I can also right click on a note on a different image. If that happens, what ever edits I make on the previous image are applied to the second image. It is kind of strange but I wonder if there is a solution for this.
druesome
@druesome I think you are tackling the problem incorrectly. You rather fix the jQuery notes plugin or get another one instead of disabling right click etc. Its the wrong solution to your problem in my opinion.
Alec Smart
Yeah it is a crude solution. I'll try to figure this thing out. Thanks Alec!
druesome