Rails 3 - AJAX 请求

发布于 2024-12-06 08:52:48 字数 530 浏览 0 评论 0原文

重命名它

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

知足的幸福 2024-12-13 08:52:48

您可以发布该请求的完整终端输出吗?我感兴趣的是 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 for rename.html.erb and not a partial like _rename.html.erb.

真心难拥有 2024-12-13 08:52:48

尝试将 _render.html.erb 显式渲染为 js 文件中的部分。 Rails 可能会与您的视图的(几乎)冲突的名称混淆。

rename.js.erb

$('div.popup').html('<%= escape_javascript(render(:partial => 'rename')) %>');

或者尝试重命名部分而不是重命名。

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

$('div.popup').html('<%= escape_javascript(render(:partial => 'rename')) %>');

Or try renaming the partial other than rename.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文