history.nette.ajax.js icon indicating copy to clipboard operation
history.nette.ajax.js copied to clipboard

[bug] broken flash messages

Open Ciki opened this issue 11 years ago • 7 comments

If I use sth. like this in presenter

$this->flashMessage('test');
$this->redirect('this');

the flash message will not show up as corresponding snippet (flashes) is not set to be redrawn after forwarding.

The workaround is to check for _fid in startup method

if (!empty($this->params[self::FLASH_KEY])) {
    $this->redrawControl('flashes');
}

but I lost more than hour to track this down..would be nice to mention this at least somewhere

Ciki avatar Sep 26 '14 09:09 Ciki

That is not a bug. It's your responsibility to invalidate snippets. Flash messages are not tied to output in any way.

Majkl578 avatar Sep 26 '14 16:09 Majkl578

ok, I forgot that line in previous example..

$this->flashMessage('test');
$this->redrawControl('flashes');
$this->redirect('this');

after redirect the snippet is not invalidated.. (which is without this extension..)

Ciki avatar Sep 26 '14 20:09 Ciki

The thing about this extension is, that if you make redirect, you make redirect :). Therefore you have to take care of this invalidation in the destination of the redirect (in the newly created app request).

vojtech-dobes avatar Sep 27 '14 13:09 vojtech-dobes

after redirect the snippet is not invalidated.. (which is without this extension..)

That's true, but without this extension, this invalidated snippet is discarded immediately by actual redirect in the browser. So with this extension, you have to think about it bit different.

vojtech-dobes avatar Sep 27 '14 13:09 vojtech-dobes

I see now but haven't realized when I used this extension for the first time. Now it seems obvious but it was not when I was hunting the 'bug' down :) All I'm asking is if any mention in readme of how this extension works & what to be aware of (need of snippet invalidation after 'redirect') would not be helpful for first-time users like I was..

Ciki avatar Sep 28 '14 08:09 Ciki

Noted. I will try to update readme soon :).

vojtech-dobes avatar Sep 28 '14 08:09 vojtech-dobes

Thx ;)

Ciki avatar Sep 28 '14 11:09 Ciki