开发者

js.erb template won't get rendered

I have the following code.

def exception_handler(e)
   flash.now[:error] =  e.message
   render 'shared/exception_handler'    
end

here is the exception_handler.js.erb

$('#flash').html(' "/shared/flash_messages" )%>');
window.scrollBy(0,-10000);
$('#flash').slideDown('slow').effect('highlight', {}, 3000).del开发者_Python百科ay(4000).slideUp('slow');

How can I get it running when I rescue an exception in controller. The strange thing is it was working before I made some changes in the code this morning.


Maybe you deleted this part

$('#flash').html('<%=escape_javascript(render :partial=> "/shared/flash_messages" ).html_safe %>');


You need to add .js.erb explicitly like this:

def exception_handler(e)
   flash.now[:error] =  e.message
   render 'shared/exception_handler.js.erb'    
end

then, you need to rename exception_handler.js.erb to _exception_handler.js.erb

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜