一旦 application.js 文件中需要 jquery,为什么销毁操作不兼容?如何在不忽略 jquery 的情况下让销毁操作再次工作?
帖子索引视图:
h1 Blog
- @posts.each do |post|
h2 = link_to post.title, post
p = post.content
p = link_to 'Edit', edit_post_path(post)
p = link_to 'Delete', post, data: {confirm: "Are you sure?"}, method: :delete
br
p = link_to 'Add a new post', new_post_path
销毁帖子控制器中的操作:
def destroy
@post = Post.find params[:id]
@post.destroy
redirect_to posts_path, :notice => "Your post has been deleted"
end
应用程序.js:
= require jquery
= require jquery_ujs
//= require turbolinks
//= require_tree
一旦我将这两个评论出来,破坏动作就会再次起作用。没有评论,删除链接只会触发表演动作……你的想法?