I’ve got an after_filter which adds code to response.body for popping
up a flash - it’s kinda handy for having flash messages appear
automatically with each ajax request, without having to explicitly
include the flash code in every single action…
However, I’m running into problems with detecting whether I’m
returning js or html. If I’m using an rjs, then I can just add the
javascript code on the end. If I’m using a partial, then I need to
wrap it in script tags. But I can’t figure out how to detect which
one I should be using.
Is there any way for my controller to detect whether the response is
going to be executed (js) or just inserted (html)?
Hi Jonathan,
Jonathan del Strother wrote:
I’m running into problems with detecting whether
I’m returning js or html.
Check out the respond_to method. A word or caution… there’s a bug
that
precludes the use of ‘:disable_with’ if you’re using a form_remote_tag
to
initiate the server-side action. There’s a recent thread where I was
having
a problem with respond_to and a couple of Railers pointed it out to me.
hth,
Bill
On 13 Sep 2006, at 13:21, Bill W. wrote:
form_remote_tag to
initiate the server-side action. There’s a recent thread where I
was having
a problem with respond_to and a couple of Railers pointed it out to
me.
Mmm, re-reading my email, I wasn’t very clear - I’m already using
respond_to to only insert the flash popup into ajax-y responses. My
problem boils down to figuring out whether I’m using Ajax.Updater or
Ajax.Request. Looking at the prototype code, I’m not so convinced
that this is possible on the server side. Maybe I could modify
Ajax.Updater to add a parameter I could detect on the server…
I eventually got around it by tweaking prototype.js to send the
expected return type in the headers. Seems to work ok, though I’d be
interested in any alternate solutions