Thanks, I focused too much on the XML syntax.
session.flash=DIV('Item deleted. ',A('(undo)',_href=URL('undo_func')))
works and renders to html with a hyperlink.
However,
session.flash=XML('<a href="%s">click me</a>' % URL('index'))
still renders to a string instead of html, feels like unexpected behavior
to me.
To allow hyperlinks in the flash message, it would suffice to bind to the
flash DIV the jQuery "dblclick" event instead of "click". So line 28 of
web2py_ajax.js would look like:
jQuery('.flash').dblclick(function(e) { jQuery(this).fadeOut('slow'); e.
preventDefault(); });
I'll leave it to the elders of web2py to decide whether this breaks
backward compatibility.
Maybe a close/dismiss/OK button on the flash would also be a good or better
solution.
I think it would be a nice feature to allow for working hyperlinks in the
flash.
Thanks for the input!
Am Mittwoch, 29. August 2012 23:49:04 UTC+2 schrieb Derek:
>
> Read Anthony's message again. It can be either XML or A, not both. Note he
> also says that you won't be able to click the link anyway.
>
> On Wednesday, August 29, 2012 2:21:59 PM UTC-7, Claudio Zambaldi wrote:
>>
>> sorry, that should read:
>>
>> XML doesn't seem to render to html but to string.
>>
>> The following line in the welcome app index:
>>
>> session.flash=XML(A('a link',URL('index')))
>>
>> result in the string
>>
>> <a href="/welcome/default/index">a link</a>
>>
>> being displayed in the flash message instead of a clickable link
>>
>> this was tested on web2py 1.99.2
>>
>> Am I missing something?
>>
>> 2012/8/29 Claudio Zambaldi <[email protected]>:
>> > Anthony, thanks for your reply.
>> >
>> > XML doesn't seem to render to html but to string.
>> >
>> > The following two lines in the welcome app index:
>> > session.flag= not (session.flag)
>> > session.flash=XML(A('a link',URL('index')))
>> >
>> > result in the string
>> >
>> > <a href="/welcome/default/index">a link</a>
>> >
>> > being displyed in the flash message instead of a clickable link
>> >
>> > this was tested on web2py 1.99.2
>> >
>> > Am I missing something?
>> >
>> >
>> >
>> > 2012/8/29 Anthony <[email protected]>:
>> >> Yes, session.flash can be HTML -- you can use web2py HTML helpers or
>> put raw
>> >> HTML code inside XML(), and it should be rendered properly.
>> >>
>> >> session.flash = A('click me', _href=URL(...))
>> >>
>> >> or
>> >>
>> >> session.flash = XML('<a href="%s">click me</a>' % URL(...))
>> >>
>> >> The problem with including a link, though, is that using the current
>> >> scaffolding app and web2py.js, clicking on the flash message causes it
>> to
>> >> hide, but the click won't register on the link. You would probably
>> have to
>> >> hack web2py.js or otherwise add some JS code to override the flash
>> click
>> >> handler in order to avoid that behavior.
>> >>
>> >> Anthony
>> >>
>> >>
>> >> On Tuesday, August 28, 2012 7:15:26 PM UTC-4, czamb wrote:
>> >>>
>> >>> Is it possible to get some html content into the session.flash
>> message?
>> >>> I would like to include an "undo" link for a delete action.
>> >>> Could also be nice to easily access newly created content.
>> >>> Thank you.
>> >>
>> >> --
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Claudio Zambaldi :: 0176-50123077 :: http://zambaldi.de
>>
>>
>>
>> --
>> Claudio Zambaldi :: 0176-50123077 :: http://zambaldi.de
>>
>
--