summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-09-29 10:29:29 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-09-29 10:29:29 +0000
commit2c97f9ecde0df139a7dff3582200b2af54d8b1c0 (patch)
tree8eb1d7cbb7c61eb20d14bc555879203eeeca5488
parent886284b33f1a670be32ff5fd2f93e76089c4d813 (diff)
downloadredmine-2c97f9ecde0df139a7dff3582200b2af54d8b1c0.tar.gz
redmine-2c97f9ecde0df139a7dff3582200b2af54d8b1c0.zip
AJAX call on the issue form resets data entered during the call (#14621).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12166 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/views/issues/update_form.js.erb2
-rw-r--r--public/javascripts/application.js19
2 files changed, 19 insertions, 2 deletions
diff --git a/app/views/issues/update_form.js.erb b/app/views/issues/update_form.js.erb
index 46fc9722e..8c94aeceb 100644
--- a/app/views/issues/update_form.js.erb
+++ b/app/views/issues/update_form.js.erb
@@ -1,4 +1,4 @@
-$('#all_attributes').html('<%= escape_javascript(render :partial => 'form') %>');
+replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
<% if User.current.allowed_to?(:log_time, @issue.project) %>
$('#log_time').show();
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 3a1b9cb79..32202839d 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -444,8 +444,10 @@ function randomKey(size) {
return key;
}
-// Can't use Rails' remote select because we need the form data
function updateIssueFrom(url) {
+ $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
+ $(this).data('valuebeforeupdate', $(this).val());
+ });
$.ajax({
url: url,
type: 'post',
@@ -453,6 +455,21 @@ function updateIssueFrom(url) {
});
}
+function replaceIssueFormWith(html){
+ var replacement = $(html);
+ $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
+ var object_id = $(this).attr('id');
+ if (object_id && $(this).data('valuebeforeupdate')!=$(this).val()) {
+ replacement.find('#'+object_id).val($(this).val());
+ }
+ });
+ $('#all_attributes').empty();
+ $('#all_attributes').prepend(replacement);
+ if (focus) {
+ $('#'+focus).focus();
+ }
+}
+
function updateBulkEditFrom(url) {
$.ajax({
url: url,