Forum: Ruby on Rails Setting flash notice via javascript?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8ac999193268eab2f987c837953a1ec3?d=identicon&s=25 nextpulse (Guest)
on 2009-05-13 22:34
(Received via mailing list)
I am using a javascript to redirect to another action. Is there a way
to set the flash [:notice] in the javascript?

So when the javascript redirects, the new action/view picks up the
flash[:notice]?

(I suspect I may have to do something like url?notice=.....)

ideas?

thanks.
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-05-14 05:06
(Received via mailing list)
On Wed, May 13, 2009 at 10:33 PM, nextpulse <robert@nextpulse.com>
wrote:
>
> thanks.

I don't think there is a way but you can use a parameter like
notice=Flash%20message
and then in the receiving action do

flash.now[:notice] = params[:notice] if params[:notice]

Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain
37df158edd0f4ca5fc2fff2e87f43487?d=identicon&s=25 Chris B. (fabrik42)
on 2009-05-14 10:06
I think it would be awkward to call a URL just to add a flash notice to
the site.
Do it in JS only, and "simulate" the flash notice, by showing it using
pure clientside javascript.

Like: document.getElementById("myEmptyFlashNoticeDiv).innerHTML = "my
notice"
8ac999193268eab2f987c837953a1ec3?d=identicon&s=25 nextpulse (Guest)
on 2009-05-14 21:35
(Received via mailing list)
@Chris: I think you mis-understood me. I am redirecting to another URL
- not to set flash. I would like to keep the context of flash notices
that was set - so the redirected url picks it up.

@ Andrew: thanks - its a similar approach I was thinking of. Thought
there may be a less 'clunky' way.


On May 14, 1:06 am, "Chris B." <rails-mailing-l...@andreas-s.net>
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (conradwt)
on 2009-05-15 02:58
(Received via mailing list)
On Thu, May 14, 2009 at 12:34 PM, nextpulse <robert@nextpulse.com>
wrote:

> wrote:
> > I think it would be awkward to call a URL just to add aflashnotice to
> > the site.
> > Do it in JS only, and "simulate" theflashnotice, by showing it using
> > pure clientside javascript.
> >
> > Like: document.getElementById("myEmptyFlashNoticeDiv).innerHTML = "my
> > notice"
> > --
> > Posted viahttp://www.ruby-forum.com/.


What's the purpose of the flash notice being transferred/available to
the
other pages?

-Conrad
This topic is locked and can not be replied to.