From d0dc01b99215177f7495e8fad7090277e9a96c72 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 12 Jan 2015 17:55:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=97=AE=E5=8D=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=9B=B8?= =?UTF-8?q?=E5=85=B3js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 4 ++-- app/views/poll/destroy.js.erb | 5 ++++- app/views/poll/index.html.erb | 9 ++++++--- config/locales/zh.yml | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 2a190166f..5f0119022 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,5 +1,5 @@ class PollController < ApplicationController - before_filter :find_poll_and_course, :only => [:edit,:update,:destory] + before_filter :find_poll_and_course, :only => [:edit,:update,:destroy] before_filter :find_container, :only => [:new,:create, :index] def index @@ -59,7 +59,7 @@ class PollController < ApplicationController end def destroy - if @poll.destroy + if @poll && @poll.destroy respond_to do |format| format.js end diff --git a/app/views/poll/destroy.js.erb b/app/views/poll/destroy.js.erb index a9efe790e..abfecb167 100644 --- a/app/views/poll/destroy.js.erb +++ b/app/views/poll/destroy.js.erb @@ -1 +1,4 @@ -alert("删除成功"); \ No newline at end of file +<% if @poll%> + $("#polls_<%= @poll.id%>").remove(); +<%else%> +<% end %> diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb index 7c1529406..39230774b 100644 --- a/app/views/poll/index.html.erb +++ b/app/views/poll/index.html.erb @@ -17,17 +17,20 @@