Description:
fixed avail bug for ajax toggle
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@287 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r148:5e03edcd8c25 - - 3 files changed: 7 inserted, 2 deleted
@@ -79,15 +79,19 | |||
|
79 | 79 | def destroy |
|
80 | 80 | Problem.find(params[:id]).destroy |
|
81 | 81 | redirect_to :action => 'list' |
|
82 | 82 | end |
|
83 | 83 | |
|
84 | 84 | def toggle |
|
85 | + respond_to do |wants| | |
|
86 | + wants.js { | |
|
85 | 87 | @problem = Problem.find(params[:id]) |
|
86 | 88 | @problem.available = !(@problem.available) |
|
87 | 89 | @problem.save |
|
90 | + } | |
|
91 | + end | |
|
88 | 92 | end |
|
89 | 93 | |
|
90 | 94 | def turn_all_off |
|
91 | 95 | Problem.find(:all, |
|
92 | 96 | :conditions => "available = 1").each do |problem| |
|
93 | 97 | problem.available = false |
@@ -26,13 +26,13 | |||
|
26 | 26 | <tr id="prob-<%= problem.id %>" name="prob-<%= problem.id %>" class="<%= (problem.available) ? "available" : "not-available" %>"> |
|
27 | 27 | <% @problem=problem %> |
|
28 | 28 | <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %></td> |
|
29 | 29 | <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %></td> |
|
30 | 30 | <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %></td> |
|
31 | 31 | <td><%= problem.date_added %></td> |
|
32 | - <td><%= problem.available %></td> | |
|
32 | + <td id="prob-<%= problem.id %>-avail"><%= problem.available %></td> | |
|
33 | 33 | <td><%= problem.test_allowed %></td> |
|
34 | 34 | |
|
35 | 35 | <td><%= link_to_remote '[Toggle]', :url => {:action => 'toggle', :id => problem.id } %></td> |
|
36 | 36 | <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td> |
|
37 | 37 | <td><%= link_to '[Show]', :action => 'show', :id => problem %></td> |
|
38 | 38 | <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td> |
You need to be logged in to leave comments.
Login now