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 Rajgarhia -- Posted via http://www.ruby-forum.com/.
Aditya Rajgarhia 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 Kilset
On 7/18/06, Henning Kilset <henning@railsfoundry.com> wrote:> > Aditya Rajgarhia 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/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. :) Regards,> Henning Kilset > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060718/7394f231/attachment.html
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 <head> of the entire page then? I mean, I can''t just put it in the <head> 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 -- Posted via http://www.ruby-forum.com/.
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 <code> layout ''otherlayout'' </code> to include that in the controller you want it in. On 7/18/06, Aditya Rajgarhia <adityar7@gmail.com> wrote:> > 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 <head> of the entire page then? I mean, I > can''t just put it in the <head> 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060718/3c122e0e/attachment.html
Aditya Rajgarhia wrote:> 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 <head> of the entire page then? I mean, I > can''t just put it in the <head> 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 >Take a look at: http://api.rubyonrails.com/classes/ActionView/Helpers/CaptureHelper.html Specifically: In your layout: <head> ... stuff <%= @content_for_head %> </head> In your template: <% content_for("head") do %> the javascript / include js file <% end %> Should do the trick. Hth -- R.Livsey http://livsey.org