Created
December 9, 2010 19:05
-
-
Save cbeer/735166 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/controllers/folder_controller.rb b/app/controllers/folder_controller.rb | |
index 9427a6f..804c7f0 100644 | |
--- a/app/controllers/folder_controller.rb | |
+++ b/app/controllers/folder_controller.rb | |
@@ -12,21 +12,30 @@ class FolderController < ApplicationController | |
session[:folder_document_ids] = session[:folder_document_ids] || [] | |
session[:folder_document_ids] << params[:id] | |
flash[:notice] = "#{params[:title] || "Item"} successfully added to Folder" | |
- redirect_to :back | |
+ respond_to do |format| | |
+ format.html { redirect_to :back } | |
+ format.js { render :json => session[:folder_document_ids] } | |
+ end | |
end | |
# remove a document_id from the folder | |
def destroy | |
session[:folder_document_ids].delete(params[:id]) | |
flash[:notice] = "#{params[:title] || "Item"} successfully removed from Folder" | |
- redirect_to :back | |
+ respond_to do |format| | |
+ format.html { redirect_to :back } | |
+ format.js { render :json => session[:folder_document_ids] } | |
+ end | |
end | |
# get rid of the items in the folder | |
def clear | |
flash[:notice] = "Cleared Folder" | |
session[:folder_document_ids] = [] | |
- redirect_to folder_index_path | |
+ respond_to do |format| | |
+ format.html { redirect_to :back } | |
+ format.js { render :json => session[:folder_document_ids] } | |
+ end | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/assets/javascripts/application.js b/assets/javascripts/application.js | |
index bc7f28f..9a4c538 100644 | |
--- a/assets/javascripts/application.js | |
+++ b/assets/javascripts/application.js | |
@@ -36,7 +36,7 @@ $(document).ready(function() { | |
$("#folder_number").text(folder_num); | |
form.attr("action",new_form_action); | |
form.children("input[type=submit]").attr("value",new_button_text); | |
- }); | |
+ }, "json"); | |
return false; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment