Rails 3 - AJAX 请求
重命名它
rename.js.erb
alert('start');
$('div.popup').html('<%= escape_javascript(render('rename')) %>');
_rename.html.erb
Some text
在终端窗口 由 ArticlesController#rename as 处理 ...
渲染的文章/_rename.html.erb(0.3ms) 渲染的文章/rename.js.erb(2.3ms)
这是我当前针对 AJAX 请求的设置。我仍然收到此错误消息*缺少模板文章/重命名*。我不明白为什么,我认为一切都应该好起来...... jQuery 库已加载。 JS 文件中的 alert
窗口不跳转... 谁能帮帮我,请问有什么问题吗?
Rename it
rename.js.erb
alert('start');
$('div.popup').html('<%= escape_javascript(render('rename')) %>');
_rename.html.erb
Some text
in terminal window
Processing by ArticlesController#rename as
...
Rendered articles/_rename.html.erb (0.3ms)
Rendered articles/rename.js.erb (2.3ms)
This is my current set up for the AJAX request. I'm still getting this error message *Missing template articles/rename *. I don't understand why, I think everything should be set alright...
jQuery library is loaded. The alert
window in JS file don't jump...
Could anyone help me, please, what is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以发布该请求的完整终端输出吗?我感兴趣的是
Renderedarticles/_rename.html.erb (0.3ms)
来自何处以及它的处理方式,因为您只是写了“...”。我唯一能想到的是你的文件命名不正确。
ArticlesController#rename
将查找rename.html.erb
而不是像_rename.html.erb
这样的部分。Can you post the full terminal output for that request? I'm interested in where
Rendered articles/_rename.html.erb (0.3ms)
is coming from and what it's being processed as since you simply wrote "...".The only thing I can think of is that your file isn't named correctly.
ArticlesController#rename
would look forrename.html.erb
and not a partial like_rename.html.erb
.尝试将 _render.html.erb 显式渲染为 js 文件中的部分。 Rails 可能会与您的视图的(几乎)冲突的名称混淆。
在 rename.js.erb 中
或者尝试重命名部分而不是重命名。
Try rendering _render.html.erb explicitly as a partial within your js file. Rails might be getting confused with the (almost) conflicting names of your views.
In rename.js.erb
Or try renaming the partial other than rename.