2021-04-30 19:26:06 +08:00
|
|
|
(function() {
|
2021-04-25 00:43:28 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function initReplaceFormListeners() {
|
2021-04-30 19:26:06 +08:00
|
|
|
$(document).on('ajax:success', 'form[data-action*="replace-form"]', function(_, { form, flash }) {
|
|
|
|
let newForm = $(form);
|
2021-04-29 00:02:18 +08:00
|
|
|
let target = this.getAttribute('data-target');
|
|
|
|
|
|
|
|
if (target) {
|
|
|
|
$(target).replaceWith(newForm);
|
|
|
|
} else {
|
|
|
|
$(this).replaceWith(newForm);
|
|
|
|
}
|
2021-04-30 19:26:06 +08:00
|
|
|
|
2021-04-25 00:43:28 +08:00
|
|
|
newForm.find('.selectpicker').selectpicker();
|
2021-04-30 19:26:06 +08:00
|
|
|
|
|
|
|
if (flash) {
|
|
|
|
HelperModule.flashAlertMsg(flash, 'success');
|
|
|
|
}
|
|
|
|
});
|
2021-04-25 00:43:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document).one('turbolinks:load', initReplaceFormListeners);
|
2021-05-02 17:36:10 +08:00
|
|
|
}());
|