You need single-quotes around
flash.fadeOut("slow")
Otherwise, as you have seen, it gets executed immediately instead of after
a delay.
On Tuesday, October 18, 2016 at 9:35:30 AM UTC-4, Marc Smith wrote:
>
> Hi,
>
> I'm relatively new to JS but the strange quote character at the
> beginning (I thought it was a back-tick, but doesn't appear it is) and
> single quote at the end in that line don't look right to me -- is that
> correct? I tried the code with Jim's change of using ".w2p_flash" but
> it still doesn't work for me.
>
> This is what the block of JS from web2py.js looks like currently:
> --snip--
> /*helper for flash messages*/
> flash: function(message, status) {
> var flash = $('.w2p_flash');
> web2py.hide_flash();
> flash.html(message).addClass(status);
> if(flash.html()) flash.append('<span id="closeflash"> ×
> </span>').slideDown();
> },
> hide_flash: function() {
> $('.w2p_flash').fadeOut(0).html('');
> },
> --snip--
>
> I tried adding this line:
> setTimeout(flash.fadeOut("slow"),5000);
>
> But the message fades in and out in about a second, and in Chrome's
> developer panel, I see a "(program):1 Uncaught SyntaxError: Unexpected
> identifier" error.
>
> Any help would be greatly appreciated.
>
>
> --Marc
>
> On Wed, Jul 13, 2016 at 6:41 PM, Jim Brouzoulis
> <[email protected] <javascript:>> wrote:
> > Thank you very much for your help! (...and sorry for the late reply)
> >
> > It didn't work at first but then I noticed a typo: the class should be
> > '.w2p_flash'.
> >
> > Regards
> > // Jim
> >
> >
> > Den måndag 11 juli 2016 kl. 10:49:08 UTC+2 skrev Massimiliano:
> >>
> >> Hi Jim,
> >> I’m doing it in this way:
> >>
> >> Edit static/web2py.js search for /*helper for flash messages*/
> >>
> >> and add this command:
> >>
> >> setTimeout(‘jQuery(".flash").fadeOut("slow")',5000);
> >>
> >> just after:
> >>
> >> if (flash.html()) flash.append('<span id="closeflash"> ×
> >> </span>').slideDown();
> >>
> >> Adjust 5000 that stands for 5 secods to your needs.
> >>
> >>
> >> On Thu, Jul 7, 2016 at 6:00 PM, Jim Brouzoulis <[email protected]>
>
> >> wrote:
> >>>
> >>> Hi everyone,
> >>>
> >>> Can I easily customise the web2py.js file to automatically hide/fade
> out
> >>> the flash message after some given time (like a few seconds) instead
> of
> >>> clicking on it? If so, how?
> >>> I have a feeling that the solution is probably not that complicated
> but
> >>> my js-skills aren't very impressive :)
> >>>
> >>> Regards
> >>> // Jim
> >>>
> >>> --
> >>> Resources:
> >>> - http://web2py.com
> >>> - http://web2py.com/book (Documentation)
> >>> - http://github.com/web2py/web2py (Source code)
> >>> - https://code.google.com/p/web2py/issues/list (Report Issues)
> >>> ---
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "web2py-users" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an
> >>> email to [email protected].
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> >>
> >>
> >> --
> >> Massimiliano
> >
> > --
> > Resources:
> > - http://web2py.com
> > - http://web2py.com/book (Documentation)
> > - http://github.com/web2py/web2py (Source code)
> > - https://code.google.com/p/web2py/issues/list (Report Issues)
> > ---
> > You received this message because you are subscribed to the Google
> Groups
> > "web2py-users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > For more options, visit https://groups.google.com/d/optout.
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.