From 5fcbde2ff13bca6f124a95ef7796941d4586f397 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 7 Dec 2015 17:29:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E5=9B=9E=E8=BD=A6=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_resource.html.erb | 33 +++++++++++++------------- config/routes.rb | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index a6d8d18c7..ae17eb733 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -361,12 +361,11 @@ if(user_id === '<%= User.current.id%>') { res_name = line.children().eq(1).children().attr('title'); res_link = line.children().eq(1).html(); - line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' + + line.children().eq(1).html( ' '+ - '<% end %>'); + '"/> '); $("#res_name").focus(); $("html,body").animate({scrollTop:$("#res_name").offset().top},1000) }else{ @@ -382,6 +381,8 @@ return str.slice(0, i + 1); } + + //恢复编辑状态到链接状态 //如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态 //如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示 @@ -395,22 +396,22 @@ if( name && name != res_name.trim()){ if(confirm('确定修改为 '+name)){ - $.post( - '<%=rename_resource_user_path(@user) %>', - "res_name="+$('#res_name').val()+"&res_id="+$("#res_id").val(), - function (data){ - if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 + $.ajax({ + url: '<%=rename_resource_user_path(@user) %>'+ "?res_name="+$('#res_name').val() + "&res_id=" + $("#res_id").val(), + type:'get', + success:function (data) + { + if (data != 'fail') {//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 last_line.children().eq(1).html(res_link); - last_line.children().eq(1).children().attr('title',name); - last_line.children().eq(1).children().attr('href',data); - last_line.children().eq(1).children().html(name.length > 17? name.substring(0,17)+'...' : name); - }else{ + last_line.children().eq(1).children().attr('title', name); + last_line.children().eq(1).children().attr('href', data); + last_line.children().eq(1).children().html(name.length > 17 ? name.substring(0, 17) + '...' : name); + } else { last_line.children().eq(1).html(res_link); res_link = null; //如果修改失败,恢复之后将res_link置空 } - }, - 'text' - ); + } + } ); }else{ last_line.children().eq(1).html(res_link); res_link = null; //如果没有做修改,恢复之后将res_link置空 diff --git a/config/routes.rb b/config/routes.rb index f6fe95a33..623a42f38 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -478,7 +478,7 @@ RedmineApp::Application.routes.draw do post "add_exist_file_to_course" post "add_exist_file_to_project" get 'resource_preview' - post 'rename_resource' + get 'rename_resource' get 'search_user_project' get 'user_resource_type' get 'user_ref_resource_search'