scinote-web/app/assets/javascripts/shared/async_dropdown.js
2022-09-02 16:54:41 +02:00

20 lines
571 B
JavaScript

/* eslint-disable no-unused-vars */
var AsyncDropdown = {
init: function($container) {
$container.on('click', '.dropdown-async button', function(e) {
var $parent = $(e.currentTarget).parent();
if ($parent.data('async-dropdown-initialized')) return;
$parent.on('show.bs.dropdown', function() {
$parent.find('ul').empty().hide();
$.get($parent.data('dropdown-url'), function(data) {
$parent.find('ul').replaceWith(data.html);
});
});
$parent.data('async-dropdown-initialized', true);
});
}
};