"Add new attachment" button works.
This commit is contained in:
parent
90c6fdc377
commit
6ea7386bd3
@ -39,4 +39,24 @@
|
||||
}, scroll_duration_msec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the queried buttons as "Add New Attachment" buttons.
|
||||
*/
|
||||
$.fn.addNewAttachmentButton = function() {
|
||||
var $button = this;
|
||||
$button.click(function() {
|
||||
console.log('Cloning last repeating group');
|
||||
var lastRepeatingGroup = $button
|
||||
.parent()
|
||||
.next('.attachments')
|
||||
.children('ul.fieldlist')
|
||||
.children('li')
|
||||
.last();
|
||||
console.log(lastRepeatingGroup.toArray());
|
||||
var cloned = lastRepeatingGroup.clone(false);
|
||||
cloned.insertAfter(lastRepeatingGroup);
|
||||
resetAttributeNames(cloned);
|
||||
cloned.find('.fileupload').each(setup_file_uploader)
|
||||
})
|
||||
}
|
||||
}(jQuery));
|
||||
|
@ -252,14 +252,7 @@ script(type="text/javascript").
|
||||
section.find('div.form-upload-progress-bar').hide();
|
||||
}
|
||||
|
||||
if (document.getElementById("attachments") !== null) {
|
||||
$("#attachments-action-add").on('click', function(){
|
||||
var lastRepeatingGroup = $('#attachments > li').last();
|
||||
var cloned = lastRepeatingGroup.clone(true);
|
||||
cloned.insertAfter(lastRepeatingGroup);
|
||||
resetAttributeNames(cloned);
|
||||
});
|
||||
}
|
||||
$("#attachments-action-add").addNewAttachmentButton();
|
||||
|
||||
if (document.getElementById("files") !== null) {
|
||||
$("#files-action-add").on('click', function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user