Does your Response Flash get in the way?

663 views
Skip to first unread message

Russell

unread,
Nov 4, 2009, 5:48:14 PM11/4/09
to web2py-users
Hi there,

A mild annoyance: Sometimes the response flash covers other text on
the screen and, when you are doing lots of testing, you are
continually clicking it to make it go away.

My suggestion is to replace web2py_ajax.html line 36:

jQuery('.flash').click(function() { jQuery(this).fadeOut('slow');
return false; });

with:

jQuery('.flash').hide().fadeIn(2000).animate({opacity: 1.0},
2000).animate({ opacity: 'hide' }, 2000);

This makes the response.flash fade in and then fade out. No clicking
required.

Thanks
Russell

mdipierro

unread,
Nov 4, 2009, 11:43:18 PM11/4/09
to web2py-users
The problem with that is that if the user is distracted, the message
fades out before he/she can read it.

Sebastian Brandt

unread,
Nov 5, 2009, 2:08:09 AM11/5/09
to web2py-users
Thnaks Russel for pointing that out. I think this is very nice.
Of course the message will be unread if the user is distracted, but
after the message is generated after user input in most cases I guess,
that should be no problem in my opinion.

Sebastian

Thadeus Burgess

unread,
Nov 5, 2009, 11:52:15 AM11/5/09
to web...@googlegroups.com
Instead of putting a timer on response.flash, I moved its location to another location on the site that does conflict with any text.

-Thadeus

Jonathan Lundell

unread,
Nov 5, 2009, 2:16:41 PM11/5/09
to web...@googlegroups.com
On Nov 5, 2009, at 8:52 AM, Thadeus Burgess wrote:

Instead of putting a timer on response.flash, I moved its location to another location on the site that does conflict with any text.

I like Gmail's approach to flash messages. They're not obtrusive, but they're still prominent enough to be noticed. And because they're relatively small, Google can reserve a portion of the page for them (which is otherwise white space), with the result that showing a flash message doesn't obscure other content, nor does it change the page layout. 

When I first registered at web2pyslices, I found the fade-out flash somewhat unhelpful, in that I didn't notice it until it was too late.

OTOH, web2pyslices has a dedicated area in the UI header for the flash message, which is nice.

Another thing I'd look at is to use color in the flash messages to indicate the message category. Notices of failed operations should look different from the routine "welcome back" message, IMO.

mr.freeze

unread,
Nov 5, 2009, 3:30:01 PM11/5/09
to web2py-users
I have increased the stay time to 8 seconds.

Russell

unread,
Nov 5, 2009, 3:41:35 PM11/5/09
to web2py-users
It does seem that a nice solution would be to position or shrink the
flash message on the default layout so that it is unlikely to cover
text. But it maybe we are trying to do too much with the flash
message? There are some messages that only deserve a quick 'flash' -
like 'logged in'. But there are some messages that are more important
that need to stick around. Perhaps we need two styles in the
layout...response.flash and response.notice?

Jonathan Lundell

unread,
Nov 5, 2009, 4:13:11 PM11/5/09
to web...@googlegroups.com

I think that'd be good, or perhaps more of an API. One way to do it
would be to attach different styles to the flash, perhaps.

For my own applications, I'd like to distinguish errors from
information notices with color. Also, if an error requires that the
user do something to correct it (that is, the landing page isn't
really what the user was after), I'd be inclined to leave it up (no
fade-out), while purely informational or greeting messages that don't
require user action would fade.

mdipierro

unread,
Nov 5, 2009, 4:39:01 PM11/5/09
to web2py-users
well, you can do

response.flash=DIV("message",_class="error")

and handle both class "flash" and class "error" via css.

villas

unread,
Nov 5, 2009, 8:01:07 PM11/5/09
to web2py-users
Yes IMO the current flash is too obtrusive. I eventually got to like
the slightly quirky left pop-up menu, but the over-size flash still
grates every time. Just making it narrower would help. Yep, I know
we can alter it ourselves :-) Thanks, David

mdipierro

unread,
Nov 5, 2009, 10:18:28 PM11/5/09
to web2py-users
If you can send me some possible css to make it better, I will
consider changing it. The only requirement is that it should be semi
transparent and color neutral.

Massimo

Jonathan Lundell

unread,
Nov 5, 2009, 10:28:42 PM11/5/09
to web...@googlegroups.com
On Nov 5, 2009, at 1:39 PM, mdipierro wrote:

>
> well, you can do
>
> response.flash=DIV("message",_class="error")
>
> and handle both class "flash" and class "error" via css.

That works fine if your flash html is a simple div (as it is in the
standard layout), but it doesn't work so well if you're trying to do
more with it.

Gmail's flash display, for example, puts its flash message in a
rounded-corner box (generated via a table). You can do that too using
the technique you show, but you really need a wrapper function once
the html gets more complex than a simple div (or the like).

BTW, with this method, does the <div> end up getting escaped?

mdipierro

unread,
Nov 5, 2009, 11:26:09 PM11/5/09
to web2py-users
no

mdipierro

unread,
Nov 5, 2009, 11:27:19 PM11/5/09
to web2py-users
you can do

def error(text):
return TABLE(TR(TD(text)),_class='error')

response.flash=error("what the ...!")

Jonathan Lundell

unread,
Nov 5, 2009, 11:32:10 PM11/5/09
to web...@googlegroups.com
On Nov 5, 2009, at 8:27 PM, mdipierro wrote:

>
> you can do
>
> def error(text):
> return TABLE(TR(TD(text)),_class='error')
>
> response.flash=error("what the ...!")

Right, that's the kind of thing I was thinking of, albeit with a more
elaborate table. Then you can use a CSS selector like:

div.flash table.error { ... }

Thanks.

mdipierro

unread,
Nov 6, 2009, 1:12:43 AM11/6/09
to web2py-users
I like the apple notifications (like current flash but smaller,
darker, on the top right corner).

Janath

unread,
Jun 8, 2012, 12:46:06 AM6/8/12
to web...@googlegroups.com
How can I change the location of response.flash. It overlaps with my menu items...

Thank you,
Janath

pbreit

unread,
Jun 8, 2012, 1:05:35 AM6/8/12
to web...@googlegroups.com
It's controlled with CSS in the web2py.css file. Look for "div.flash".

With the new bootstrap support, I put this in my layout.html:

    {{if response.flash:}}
    <div class="alert">
      <button class="close" data-dismiss="alert">×</button>
      {{=response.flash}}
    </div>
    {{pass}}

Right below: <div class="container">

Annet

unread,
Jun 8, 2012, 1:26:07 AM6/8/12
to web...@googlegroups.com
I have been struggling with the flash messages as well. At the moment I have a separate view flash.html:

{{if response.flash:}}
  <div class=" alert {{if alert:}}{{=alert}}{{else:}}{{alert-info}}{{pass}}">
    <a class="close" data-dismiss="alert">x</a>
    {{=response.flash}}
  </div> <!-- /alert -->
{{pass}}

In this view I use Bootstrap's alerts to style the flash messages. 'alert-info' is the one I use most, in case I need another alert set it in the function:

def index():
    ...
    if form.process().accepted:
        ...
        alert='alert-success'
    elif form.errors:
        alert='alert-error'
    else:
        ...
   return dict(alert=alert, ...)

In my views I simply include {{include 'flash.html'}}

This works for now, to come up with a more sophisticated way to set the alerts is on my to do list.


Annet

Andreas Wienes

unread,
Oct 10, 2013, 1:27:48 PM10/10/13
to web...@googlegroups.com
Is Annet's solution still the best way handling flash messages?

Derek

unread,
Oct 10, 2013, 1:33:05 PM10/10/13
to web...@googlegroups.com
It depends on what your complaint with flash is...

Paul Ellis

unread,
Feb 13, 2017, 3:12:13 AM2/13/17
to web2py-users, thad...@thadeusb.com
Hi Thadeus,

How did you move the flash messages?
Reply all
Reply to author
Forward
0 new messages