|
16 | 16 | var input = $(this), |
17 | 17 | files = $(this).prop('files'); |
18 | 18 |
|
19 | | - var n_existent = $('#' + $(this).data('attach-id') + ' .jquery_attachment_block').length; |
| 19 | + var n_existent = $('.jquery_attachment_block').length; |
20 | 20 |
|
21 | 21 | for(var i=0,file;file=files[i];i++) { |
22 | 22 | var num = n_existent + i; |
|
29 | 29 | +'<div class="media-body check_related_text">' |
30 | 30 | +'<div><span id="new_attachment_'+num+'_display_new_filename">'+file.name+'</span> <s id="new_attachment_'+num+'_display_original_filename"></s>' |
31 | 31 |
|
32 | | - // Button |
| 32 | + // Edit button |
33 | 33 | +'<button type="button" role="button" class="btn btn-light btn-xs edit_attachment"'; |
34 | 34 |
|
35 | 35 | if ($('#'+$(this).data('attach-id')).data('new-attachment-modal-id')){ |
|
123 | 123 | $(editdiv).find('#attachment_form_prefix').val(prefix); |
124 | 124 |
|
125 | 125 | if ($(this).attr('data-modal-id')){ |
| 126 | + // Showing modal |
126 | 127 | $('#'+$(this).data('modal-id')).modal('show'); |
| 128 | +
|
| 129 | + // Pass back-div |
| 130 | + $(editdiv).find('.attachment_form_submit').attr('data-back-div', $(this).closest('.attached_list').prop('id')); |
127 | 131 | }else{ |
| 132 | + // Switching visible form inside modal |
128 | 133 | $(editdiv).show(); |
129 | 134 | $('#'+$(this).data('back-div')).hide(); |
130 | 135 | } |
|
180 | 185 | }else{ |
181 | 186 | $('#'+prefix+'display_original_filename').text(' - '+original_filename); |
182 | 187 | } |
183 | | - $('#'+$(this).data('back-div')).find('#'+prefix+'display_new_filename').text(new_filename); |
| 188 | +
|
| 189 | + $('#'+$(this).attr('data-back-div')).find('#'+prefix+'display_new_filename').text(new_filename); |
| 190 | + |
184 | 191 | if ($(fieldset).find('#attachment_form_description').val() != ""){ |
185 | | - $('#'+$(this).data('back-div')).find('#'+prefix+'display_description').text($(fieldset).find('#attachment_form_description').val()); |
| 192 | + $('#'+$(this).attr('data-back-div')).find('#'+prefix+'display_description').text($(fieldset).find('#attachment_form_description').val()); |
186 | 193 | }else{ |
187 | | - $('#'+$(this).data('back-div')).find('#'+prefix+'display_description').text($('#'+prefix+'display_description').data('mimetype')); |
| 194 | + $('#'+$(this).attr('data-back-div')).find('#'+prefix+'display_description').text($('#'+prefix+'display_description').data('mimetype')); |
188 | 195 | } |
189 | 196 |
|
190 | 197 | if ($(fieldset).find('#hide_modal_id').length){ |
191 | 198 | $('#'+$(fieldset).find('#hide_modal_id').val()).modal('hide'); |
192 | 199 | }else{ |
193 | | - $('#'+$(this).data('edit-div')).hide(); |
194 | | - $('#'+$(this).data('back-div')).show(); |
| 200 | + $('#'+$(this).attr('data-edit-div')).hide(); |
| 201 | + $('#'+$(this).attr('data-back-div')).show(); |
195 | 202 | } |
196 | 203 |
|
197 | 204 | e.preventDefault(); |
|
0 commit comments