views:

56

answers:

3

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

A: 

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);
patrick dw
Thanks. It works perfectly.
Mikkel
@Mikkel - You're welcome. :o)
patrick dw
+1  A: 

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

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

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);
adardesign