scinote-web/app/assets/javascripts/shared/swap_remote_container.js

19 lines
538 B
JavaScript
Raw Normal View History

2021-04-18 23:19:16 +08:00
(function () {
'use strict';
function initSwapRemoteContainerListeners() {
$(document).on('click', 'a[data-action="swap-remote-container"]', function(el) {
let element = el.target;
el.stopPropagation();
el.preventDefault();
$.get(element.getAttribute('href')).then(function({html}) {
let target = element.getAttribute('data-target')
document.getElementById(target).insertAdjacentHTML(html)
})
})
}
$(document).on('turbolinks:load', initSwapRemoteContainerListeners);
})();