简体   繁体   English

无法在Rails中使用jQuery加载新表单

[英]Not able to load new form using jquery in rails

I was looking at Ryan Bates screencast http://railscasts.com/episodes/136-jquery-ajax-revised on how to load new form in the index.html.erb using jquery. 我正在看Ryan Bates截屏视频http://railscasts.com/episodes/136-jquery-ajax-revised ,了解如何使用jquery在index.html.erb中加载新表格。

Here is my index.html.erb 这是我的index.html.erb

<%= link_to 'New Mail', new_mail_path, id: "new_mail", remote: true %>

Here is my new.js.erb 这是我的new.js.erb

$("#new_mail").hide().after('<%= j render("form") %>')

but this is not working. 但这不起作用。 When trying to debug (in chrome), under Console, there are no errors but in Network, I am seeing "304 Not Modified" response instead of 302, any help ? 尝试调试(在Chrome中)时,在控制台下,没有错误,但是在网络中,我看到的是“ 304 Not Modified”响应,而不是302,有什么帮助吗?

Thanks 谢谢

EDIT - it worked, I eventually had to put "format.js" in create method sigh 编辑-它的工作,我最终不得不把“format.js”在创建方法叹息

replace 更换

$("#new_mail").hide().after('<%= j render("form") %>')

with

$("#new_mail").after('<%= j render("form") %>');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM