Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Visit chat. Related Hot Network Questions. Question feed. I think this is better because a you don't have to think about it b "has the user seen it?
Max Williams Max Williams Maybe a dumb question, but is it possible that doing this deletes another flash that is about to be rendered? Bradford - i don't think so: i just clear the three flash keys that i've rendered. There's no way they get cleared without being rendered, and nothing can happen in between them getting rendered and cleared, since the clearing happens in the same partial.
Late to the game, but I love this. I just tried this. I think flash. As a result, it could display an empty message for the key deleted. CoderDave CoderDave 1 1 gold badge 9 9 silver badges 11 11 bronze badges.
In my experience, this is the best way to do it unless you need your flash messages to persist. I don't know why templates maybe the scaffolds do?
Flash is still not disappearing — Nimish. Nimish Nimish 11 11 silver badges 27 27 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. I made 2 small changes to my app to make flash behave better when an Ajax call is made.
Unfortunately, the flash is not cleared because you haven't visited another action, so you end up with the flash message redundantly displaying a 2nd time. I use it to controll the logic of when to show the flash, and also control some animations for hiding and showing the flash.
It's a nice simple plugin. The first trick is something I learned at work. This will allow us to render the flash in a normal template, but also allow us to replace the flash in an inline render. In my main template, I do a normal:. I stripped out the above code and realized the flash was being set through the session. Maybe it will help you. Now when I click my AJAX enabled link, the controller action is executed, the flash message is set, the controller loads the js.
My original view is updated with the flash message and all is right with the world. You can include format. After several hours of searching I realized I was already doing what needed to be done by passing the following lines in my controller:.
0コメント