简体   繁体   中英

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.

Here is my index.html.erb

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

Here is my 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 ?

Thanks

EDIT - it worked, I eventually had to put "format.js" in create method sigh

replace

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

with

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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