I’m wondering if this is a good idea or not, either way I’d like you guys opinion on how to best achieve this sort of messaging popup system I have in my app.
Under some occasions I want to popup a lightbox for users when certain actions are triggered. I already have the lightbox working and opening when when my controller returns JS for a request.
Here is the senario, I want to check if a user has new messages when a new request is made, and if they do I want to show the messages in my lightbox when the new page is loaded.
Should I just put some JS at the bottom of my <body> and render it if the user has messages? Or should I use like flash[:notice] and have it render as JS or something… I’m a bit stuck you see.
Don’t use flash notices, this is not what they are for at all. I would have something in the layout like this:
obviously here i’m guessing at your messages’ methods but you get the idea. .inspect will give it an array of strings, you could give it the message data as a json object or whatever.