2021-04-30 19:26:06 +08:00
|
|
|
(function() {
|
2021-04-29 00:02:18 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function initRemoteDestroyListeners() {
|
2021-04-30 19:26:06 +08:00
|
|
|
$(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');
|
|
|
|
}
|
|
|
|
});
|
2021-04-29 00:02:18 +08:00
|
|
|
|
|
|
|
$(document).on('ajax:error', 'a[data-action*="remote-destroy"]', function(_, data) {
|
|
|
|
HelperModule.flashAlertMsg(data.responseJSON.flash, 'danger');
|
2021-04-30 19:26:06 +08:00
|
|
|
});
|
2021-04-29 00:02:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document).one('turbolinks:load', initRemoteDestroyListeners);
|
|
|
|
})();
|