Skip to content

Commit

Permalink
make JS for checkbox work somewhat more consistently
Browse files Browse the repository at this point in the history
I have to admit I dn't completely understand what's going on here, but for folder/selected items checkbox, without this change the HTML response was being triggered by a checkbox check,resulting in an expensive page render that didn't need to happen.
  • Loading branch information
jrochkind committed Jun 23, 2011
1 parent 8c1e297 commit 319fd77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/controllers/folder_controller.rb
Expand Up @@ -24,17 +24,17 @@ def update
# remove a document_id from the folder. :id of action is solr_doc_id
def destroy
session[:folder_document_ids].delete(params[:id])

unless request.xhr?
respond_to do |format|
format.html do
flash[:notice] = "#{params[:title] || "Item"} successfully removed from selected items"
redirect_to :back
end

respond_to do |format|
format.html do
flash[:notice] = "#{params[:title] || "Item"} successfully removed from selected items"
redirect_to :back
end
else
render :text => "OK"
end
format.js do
render :json => {"OK" => "OK"}
end
end

end

# get rid of the items in the folder
Expand Down
Expand Up @@ -259,6 +259,7 @@ $(document).ready(function() {

$.ajax({
url: form.attr("action"),
dataType: 'json',
type: form.attr("method").toUpperCase(),
data: form.serialize(),
error: function() {
Expand Down

0 comments on commit 319fd77

Please sign in to comment.