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?

ā€“
Opportunities multiply as they are seized.
ā€“Sun Tzu

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 I. said the following on 02/26/2007 02:56 PM:

reference material on things of this nature.

                          :action => 'accesscontrol',
--
Opportunities multiply as they are seized.
    --Sun Tzu

ā€“
Give a man a fish, and youā€™ll feed him for a day. Give him a religion,
and heā€™ll starve to death while praying for a fish.
ā€“Timothy Jones