diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 043552872..d932d8b4d 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -30,8 +30,7 @@ class ZipdownController < ApplicationController if file_count > 0 zipfile = zip_bid bid else - render file: 'public/no_file_found.html' - return + zipfile = {:message => "no file"} end elsif params[:obj_class] == "HomeworkCommon" homework = HomeworkCommon.find params[:obj_id] @@ -41,8 +40,7 @@ class ZipdownController < ApplicationController if file_count > 0 zipfile = zip_homework_common homework else - render file: 'public/no_file_found.html' - return + zipfile = {:message => "no file"} end else logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!" diff --git a/public/javascripts/application.js b/public/javascripts/application.js index d9100b0bb..c514e8940 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -901,24 +901,30 @@ $(function(){ $('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) { if(status == 'success'){ var res = JSON.parse(data.responseText); - if(res.length<1){ - return; + if(res.length == null){ + alert("该作业没有任何附件可下载"); } - if(res.length==1){ - location.href = '/zipdown/download?file='+res[0].file;return; + else if(res.length<1){ + return; } - document.getElementById('light').style.display='block'; - $container = $('#light .upload_box_ul'); - $container.empty(); - for(var i = 0; i 1){ - des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; - } else { - des = '第'+res[i].index+'个学生的作品下载'; + else + { + if(res.length==1){ + location.href = '/zipdown/download?file='+res[0].file;return; } - $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + document.getElementById('light').style.display='block'; + $container = $('#light .upload_box_ul'); + $container.empty(); + for(var i = 0; i 1){ + des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; + } else { + des = '第'+res[i].index+'个学生的作品下载'; + } + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + } } } });