我想學習使用JavaScript在Rails和我在http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/的Rails 3.0到3.1的JavaScript錯誤
下一個教程即使教程針對3.0編寫,因爲Rails的3.1是出我使用它,並運行進入錯誤。在「AJAX表單提交」部分的教程之後,它構建了一個包含以下內容的js.erb文件;
$('body').html("<h1><%= escape_javaScript(@post.title) %></h1>").append("<%= escape_javaScript(@post.content) %>");
我在服務器日誌中收到以下錯誤;
ActionView::Template::Error (undefined method `escape_javaScript' for #<#<Class:0x00000100917048>:0x0000010084b0d8>):
1: $('body').html("<h1><%= escape_javaScript(@post.title) %></h1>").append("<%=escape_javaScript(@post.content) %>");
這是一個3.0到3.1的轉換問題嗎?有人能指引我朝着正確的方向嗎?
謝謝!
我沒想到讀評論,感謝您指出了這一點。當我遇到這個錯誤時,我想我已經很累了... – SteveO7