开发者

How to Render a JS response

开发者 https://www.devze.com 2023-03-19 18:56 出处:网络
I have the following in my controller: return render :js => \"alert(\'H开发者_JS百科ello Rails\');\"

I have the following in my controller:

  return render :js => "alert('H开发者_JS百科ello Rails');"

Problem is it shows up as text and isn't running as JavaScript. Ideas why?


You just need to remove the "return". The correct code would read

render :js => "alert('Hello Rails');"
0

精彩评论

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