mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-12 20:24:43 +08:00
24 lines
596 B
JavaScript
24 lines
596 B
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
function initReplaceFormListeners() {
|
|
$(document).on('ajax:success', 'form[data-action*="replace-form"]', function(_, { form, flash }) {
|
|
let newForm = $(form);
|
|
let target = this.getAttribute('data-target');
|
|
|
|
if (target) {
|
|
$(target).replaceWith(newForm);
|
|
} else {
|
|
$(this).replaceWith(newForm);
|
|
}
|
|
|
|
newForm.find('.selectpicker').selectpicker();
|
|
|
|
if (flash) {
|
|
HelperModule.flashAlertMsg(flash, 'success');
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).one('turbolinks:load', initReplaceFormListeners);
|
|
}());
|