Hi, I''m trying to open a modal popup window using redbox to display a styled notification/alert to the user. The helpers in the redbox documentation only describe how to open a redbox when the user clicks on a link, e.g., link_to_redbox() or link_to_remote_redbox(). Is there any way to open a redbox, or a different type rails- compatible modal popup, from inside a controller action? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ermmm I''m a newb but I think you should look into the redbox.js file and see if you can call some of the functions in there directly instead of via link_to_redbox calls....activateRBWindow might be a useful one? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phil Tayo wrote:> ermmm I''m a newb but I think you should look into the redbox.js file and > see if you can call some of the functions in there directly instead of > via link_to_redbox calls....activateRBWindow might be a useful one?also maybe you can help me out with my problem...do you know how to get the redbox to appear in the centre of the page? at the moment it seems stuck to the top of the window... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This interested me. There may be better modal solutions than redbox for your need, but if you are already using redbox then you may want to use it. The easiest way I found was to create a hidden div in the normal view. eg a div with id=''my_box'' Set the div style to display: none It doesnt matter where it is positioned because redBox clones it In the controller I am assuming that you are already responding to an ajax call so in the render : update add page << "RedBox.showInline(''my_box'')" There may be some bits and pieces to tidy, but that worked for me. hth Tonypm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phil wrote:> also maybe you can help me out with my problem...do you know how to get > the redbox to appear in the centre of the page? at the moment it seems > stuck to the top of the window...In the redbox.js file (in public/javascripts) in setOverlaySize: function() I have done this. (addition of one line of code) // added by APM to account for using absolute positioning in my content. // for some reason, the above calculations dont give a large enough height. It is // only the size of the banner. // When the scrollbars appear on the windon, then all is ok. This is because the first // option innerHeight+scrollMaxY is used. if (yScroll < window.innerHeight) { yScroll=window.innerHeight //Added by APM } $("RB_overlay").style[''height''] = yScroll +"px"; }, I believe that there are some other solutions in the comments on the web page for redbox, (version 2). I have not worked with redbox for a while, so I do not have it at my fingertips. There is also something I recall about using position:fixed which also helps position calculations. hth Tonypm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Anton J Aylward
2008-Jan-21 00:59 UTC
Re: Open a (redbox) modal popup from inside a controller?
tonypm said the following on 20/01/08 12:12 PM:> > In the controller I am assuming that you are already responding to an > ajax call so in the > render : update > > add > page << "RedBox.showInline(''my_box'')" > > There may be some bits and pieces to tidy, but that worked for me.I don''t think that''s a valid assumption. I can envision a whole pile of applications where view, delete, hoojum, snarf and many other methods in the controller trigger the redbox.. As in ... record = Page.find(:first, ... param[ whatever ] ..) begin if ! record.can_do(action, current_user) then if current_user.nil? then Redbox.login("You need to be logged in") retry end Redbox.alert("You don''t have permission to #{action} this record") # don''t redisplay anything. end ... end You can argue that things like the ''edit'' button should be grayed out and inoperative if the can_do for it is negative. I can argue that it shouldn''t be and that the controller should respond with a login prompt. Ultimately its up to the guy paying for the application to decide on the policy. But I, and I think others, would like to know how to handle it in the controller pretty much the way I''ve sketched out and to have anything in the ''update'' or ''render''. Access control issues should be dealt with earlier. -- "Cutting the space budget really restores my faith in humanity. It eliminates dreams, goals, and ideals and lets us get straight to the business of hate, debauchery, and self-annihilation." -- Johnny Hart --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---