-$('#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();
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',
});
}
+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,