mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-18 15:13:21 +08:00
19 lines
623 B
JavaScript
19 lines
623 B
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
function initRemoteDestroyListeners() {
|
|
$(document).on('ajax:success', 'a[data-action*="remote-destroy"]', function({ currentTarget, flash }) {
|
|
let target = currentTarget.getAttribute('data-target');
|
|
document.querySelector(target).remove();
|
|
if (flash) {
|
|
HelperModule.flashAlertMsg(flash, 'success');
|
|
}
|
|
});
|
|
|
|
$(document).on('ajax:error', 'a[data-action*="remote-destroy"]', function(_, data) {
|
|
HelperModule.flashAlertMsg(data.responseJSON.flash, 'danger');
|
|
});
|
|
}
|
|
|
|
$(document).one('turbolinks:load', initRemoteDestroyListeners);
|
|
}());
|