Why is the proper "respond_to" format not getting called?
Posted
by humble_coder
on Stack Overflow
See other posts from Stack Overflow
or by humble_coder
Published on 2010-04-28T00:14:10Z
Indexed on
2010/04/28
0:23 UTC
Read the original article
Hit count: 290
Hi All,
I'm having a bit of an odd issue. Really too odd to type out, but here goes. Basically I have a controller that refuses to "respond_to" using javascript unless I assign my "chart.generate_xml" to a variable before the "respond_to" block like so:
@xml = @chart.generate_xml(@begin_date,@end_date,1.hour)
respond_to do |format|
format.html
format.js{
render :update do |page|
page.insert_html :bottom, "chart-div", @xml
#page.insert_html :bottom, "chart-div", @chart.generate_xml(@begin_date,@end_date,1.hour)
end
}
If I remove the upper "@xml= …" portion and go with the lower "page.insert", the "format.js" section doesn't get called. And if I try to force the format with "request.format = :js", I get the javascript returned as text. I'm not doing anything special here in that method call, so I'm not sure why it would choose to respond any differently.
FWIW, the method that triggers this controller action is using JS to do so, so I'm confused as to why "format.js" isn't always getting called. Thoughts?
Best.
© Stack Overflow or respective owner