Modal Ackowledge

At the moment I have controller that deal with error messages and acknowledgements. I redirect to this with a message parameter and the type of event (which determines if the icon is a smilie, a bomb, an exclamation mark or a question mark) and the url to go to on the OK button.

You are probably familiar with this kind of thing on the GUI of your operating system :slight_smile:

However it seems heavy handed to send a complete new page in many conditions. For example, access control errors could probably be better served by a pop-up that when ack'd leaves the user where he was.

I realise that this will require identifying what parts of the code need a pop-up modal rather than a sequential modal.

My question is this: Is there a simple way to "render" a pop-up modal?

Second question: Am I better off with

  @item = Item.find( .... )   if @item.access.edit?       ....   else # Modal page       redirect_to ( :controller = 'oops',                           :action => 'accesscontrol',         :class => 'Item', :object => @item,         :message => "Cannot edit",         :return_url => ???             )   end

or am I better trying to set up some kind of exception handler?

Since a pop-up window would be something opened on the client’s PC, you would be required to use javascript to open one. This is relatively easy, all you have to do is have an onclick function for whatever generates the error (say they have bad info in a form, and when they click on submit, you want to use a popup… then you would add an onclick to the submit button), and have the JS for the onclick be something like alert(‘You screwed up the form… no soup for you!’)

There are plenty of sites on the internet showing how to use the JS alert function… you can check w3c, they tend to have some good reference material on things of this nature.

Yes, I've hunted down a few like RedBox.

But they all see to work by having the page already on the client having the stuff that the popup is made of.

So.imagine a wiki page like - yes I know this isn't Rails - http://twiki.org/cgi-bin/view/Codev/TWikiOnMemoryStick there are 84 "internal" links, that is links that get dealt with by the wiki engine. Some pages have a lot more!

Each one of those would need the ability to trigger at least one RedBox. (One for access control but maybe others)

I find this a bit overwhelming. A DRY violation?

It also puts the process into the generation of the page and not at the response at the server - where the information about the page being linked to resides. This doesn't make sense to me.

Now even if I can just get one RedBox on each page that is somehow triggered by the ... I don't know what ... it still seems I have to embed in the page all the information that I was trying to encapsulate in the "Oops" error handler (oops_controller.rb)

This doesn't make sense to me.

Then there is the matter of fall-back in the absence of JavaScript to the way I'm doing it at the moment with the Oops controller being a controller and handing out pages and having a "return to" or "go to next" in the "OK" button.

I'm now hoping that there is some way to mix AJAX and RedBox, having a generic box that the Oops controller can modify the DOM to produce the 'popup' modal dialogue box, fill it AND deal with the response.

But I'm afraid putting it all together is beyond me, so I'm hoping there is a genius out there who can.

Luke Ivers said the following on 02/26/2007 02:56 PM: