Question

How can i use the jQuery live function as a right click listener?

I've used this plugin: http://abeautifulsite.net/2008/05/jquery-right-click-plugin for right click event listening. But it isn't live, which is a problem for me.

Hope you can help

(btw. sorry for my bad english)

Thanks in advance

Was it helpful?

Solution

rightClick() is just a function that assigns regular mouse events. The function disables the context menu.

You may be better off just calling rightClick() on your images directly in the code that dynamically creates them.

var $myNewImage = $('<img src="some/path.jpg" />');
    $myNewImage.rightClick(function(){
                               // Your right click code
                           });

$myNewImage.appendTo(selector);

OTHER TIPS

I haven't gone thru the plugin code but try this out.

$("#selector").live("rightClick", function(e) {
     // Do something
});

Try:

var $myNewImage = $('<img src="some/path.jpg" />');
$myNewImage.bind("rightClick",function(){
                           // Your right click code
                       });

$myNewImage.appendTo(selector);

Or if you like chaining:

 var $myNewImage = $('<img src="some/path.jpg" />')
     .bind("rightClick",function(){
     // Your right click code
     })
    .appendTo(selector);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top