Right-click popup menu?

Hi,

I have a partial frame on the side of a page which shows the current
users logged in (as text). Now, I would like to be able to right-click
on each user’s name, and get a menu containing links such as “View
Profile”, “Send Message”, etc. These links could open in a new window.

Is this possible? Any help would be greatly appreciated.

Thanks,

Aditya R.

Aditya R. wrote:

Hi,

I have a partial frame on the side of a page which shows the current
users logged in (as text). Now, I would like to be able to right-click
on each user’s name, and get a menu containing links such as “View
Profile”, “Send Message”, etc. These links could open in a new window.

Is this possible? Any help would be greatly appreciated.

It certainly is, trough some javascript trickery. The Yahoo UI library
does this :

http://developer.yahoo.com/yui/examples/menu/contextmenu.html

The YUI homepage is at

http://developer.yahoo.com/yui/

Regards,
Henning K.

On 7/18/06, Henning K. [email protected] wrote:

It certainly is, trough some javascript trickery. The Yahoo UI library
does this :

http://developer.yahoo.com/yui/examples/menu/contextmenu.html

The YUI homepage is at

http://developer.yahoo.com/yui/

Even though it’s possible, it’s generally considered a bad idea. For one
thing, what do people with only one mouse button do (Mac users). Also,
it
makes the browser behave in a way that the user doesn’t expect. If a
user is
right clicking, they’re probably doing it to get to the browser’s
context
menu.

You’d be better off making the menu appear when the user left clicks on
the
name. Also, that’s just setting an onclick method so there’s less
JavaScript
trickery. :slight_smile:

Regards,

Wouldn’t the users browser just cache the javascript anyway, so you are
only
really loading it once? You could make a separate layout and then use

layout ‘otherlayout’
to include that in the controller you want
it
in.

Thanks for the replies. I can just to the onclick for the left mouse
button. However, there’s still a problem. I have the javascript function
to get such a menu on a regular html file.

But the user list on my rails page is actually a partial layout. How do
I put the javascript on the of the entire page then? I mean, I
can’t just put it in the of the partial layout. And I obviously
don’t want to put it in the entire layout because other pages that use
the layout don’t use this javascript.

Thanks

Aditya R. wrote:

Thanks

Take a look at:

http://api.rubyonrails.com/classes/ActionView/Helpers/CaptureHelper.html

Specifically:

In your layout:

... stuff <%= @content_for_head %>

In your template:

<% content_for(“head”) do %>
the javascript / include js file
<% end %>

Should do the trick.

Hth