删除链接已停止工作data-method ='delete'但转到显示页面 [英] Delete links stopped working data-method='delete' but goes to show page

查看:240
本文介绍了删除链接已停止工作data-method ='delete'但转到显示页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚注意到我的应用程序中的所有各种删除链接现在只是显示页面。这个应用程序从rails 2.3.8开始,现在是rails 3.2.17

I just noticed that all the various delete links in my application now just go to show pages. This application began as rails 2.3.8, it is now rails 3.2.17

rails代码示例:

Examples of the rails code:

控制器,

def destroy
  @group = Group.find(params[:id])
  @group.destroy    
  respond_to do |format|
    format.html { redirect_to(groups_url) }
    format.xml  { head :ok }
  end
end 

并且,

def destroy
  @link = Link.find(params[:id])
  @link.destroy
  respond_to do |format|
    format.html { redirect_to(links_url) }
  end 
end 

哪个生成:

HTML,

<a rel="nofollow" data-method="delete" data-confirm="Sure?" href="/groups/35">
x
</a>

并且,

<a rel="nofollow" data-method="delete" data-confirm="Sure?" href="/links/8">
x
</a>

我注意到我有,

= javascript_include_tag "application"

在我的应用程序布局模板和我尝试更新,

In my application layout template and I tried updating that to be,

= javascript_include_tag :defaults

但它没有帮助解决这个问题,仍然会显示页面而不是删除,更糟糕的是,这样做会阻止我的所有其他javascript工作!例如自动将用户留在搜索字段,日期选择器日历等。

But it didn't help with this issue, still going to show page and not deleting and worse, doing this stopped all my other javascript from working! Such as leaving user on the search field automatically, the date-picker calendar, etc.

我的application.js文件具有:

My application.js file has:

//= require jquery-1.7.2.min
//= require jquery-ui-1.8.22.custom.min
//= require default_on_first_input_field
//= require row_shading
//= require long_or_short_details
//= require sortable_hook
//= require date-picker
//= require_self


推荐答案

答案是我需要添加这一行:

The answer was that I needed to add just this line:

//= require jquery_ujs

到我的js清单。这解决了它。我的清单现在看起来像:

to my js manifest. This fixed it. My manifest now look like:

// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//
//= require jquery-1.7.2.min
//= require jquery-ui-1.8.22.custom.min
//= require jquery_ujs
//= require default_on_first_input_field
//= require row_shading
//= require long_or_short_details
//= require sortable_hook
//= require date-picker
//= require_self

这篇关于删除链接已停止工作data-method ='delete'但转到显示页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆