diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index c36877092..9ad46cd69 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -221,24 +221,36 @@ class StudentWorkController < ApplicationController def update if params[:student_work] + @submit_result = true @work.name = params[:student_work][:name] @work.description = params[:student_work][:description] @work.project_id = params[:student_work][:project] @work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@work) if @work.save +=begin respond_to do |format| format.html { flash[:notice] = l(:notice_successful_edit) redirect_to student_work_index_url(:homework => @homework.id) } +=end + @student_work = @work + respond_to do |format| + format.js end return end end +=begin respond_to do |format| format.html{redirect_to edit_student_work_url(@work)} end +=end + @submit_result = false + respond_to do |format| + format.js + end end def show diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index 25a65f039..517a238b0 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -26,7 +26,7 @@
- <%= labelled_form_for @work,:html => { :multipart => true } do |f|%> + <%= labelled_form_for @work,:html => { :multipart => true },:remote=>true do |f|%>
提示:作品名称和描述中不要出现真实的姓名信息
@@ -52,7 +52,7 @@
- 确定 + 确定 <%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%>
@@ -60,3 +60,12 @@ <% end%> + \ No newline at end of file diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index db83fd432..fdf1e31a3 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -111,11 +111,20 @@
- 确定 + 确定 <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%>
<% end%> - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/student_work/update.js.erb b/app/views/student_work/update.js.erb new file mode 100644 index 000000000..79733db31 --- /dev/null +++ b/app/views/student_work/update.js.erb @@ -0,0 +1,16 @@ +<% if @submit_result%> +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_information') %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("anonymos"); +<% else %> +window.location.href = '<%= edit_student_work_url(@work)%>'; +<% end %> + +function clickCanel() { + hideModal('#popbox02'); + window.location.href = '<%= student_work_index_url(:homework => @homework.id)%>'; +} \ No newline at end of file diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 0c7f4156f..84e087c49 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -954,13 +954,19 @@ function regexStudentWorkDescription() function new_student_work() { if(regexStudentWorkName()&®exStudentWorkDescription()) - {$("#new_student_work").submit();} + { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } } function edit_student_work(id) { if(regexStudentWorkName()&®exStudentWorkDescription()) - {$("#edit_student_work_" + id).submit();} + { + $("#edit_student_work_" + id).submit(); + $("#ajax-indicator").hide(); + } } // diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index ca7b28ee7..a0647b592 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -250,13 +250,19 @@ function regex_evaluation_num(){ function new_student_work() { if(regexStudentWorkName()&®exStudentWorkDescription()) - {$("#new_student_work").submit();} + { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } } function edit_student_work(id) { if(regexStudentWorkName()&®exStudentWorkDescription()) - {$("#edit_student_work_" + id).submit();} + { + $("#edit_student_work_" + id).submit(); + $("#ajax-indicator").hide(); + } } //验证作品名称