mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 14:17:00 +08:00
27 lines
944 B
JavaScript
27 lines
944 B
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
function initSwapRemoteContainerListeners() {
|
|
$(document).on('click', 'a[data-action="swap-remote-container"]', function(ev) {
|
|
let element = ev.currentTarget;
|
|
ev.stopImmediatePropagation();
|
|
ev.stopPropagation();
|
|
ev.preventDefault();
|
|
|
|
$.get(element.getAttribute('href')).then(function({ html, flash }) {
|
|
let targetID = element.getAttribute('data-target');
|
|
let targetElement = $(element).closest(targetID);
|
|
let newContainer = $(html).find(targetID).length ? $(html).find(targetID) : $(html);
|
|
targetElement.replaceWith(newContainer);
|
|
newContainer.find('.selectpicker').selectpicker();
|
|
newContainer.find('.new-assignment-user-search').focus();
|
|
|
|
if (flash) {
|
|
HelperModule.flashAlertMsg(flash, 'success');
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
$(document).one('turbolinks:load', initSwapRemoteContainerListeners);
|
|
}());
|