<script>
$(document).ready(function () {
getStructure();
});
$('.card').on('click', '.children', function () {
$card = $(this).closest('.card');
$card_text = $(this).closest('.card-header').siblings('.card-body').children('.card-text')
if ($(this).attr('data-downloaded') == 'false') {
$(this).attr('data-downloaded', 'true')
getStructure($card.attr('data-parent'), $card_text)
}
else {
}
});
function getStructure(id, root) {
var url = '{{route('getDepartmentsStructure')}}';
var place = document.getElementById('root')
if (id) url = url + '?id=' + id;
if (root) place = root;
$.ajax({
url: url,
dataType: 'html',
cache: false,
success: function (data) {
$(place).append(data)
}
});
}
</script>
$('.children').click(function () {
$card = $(this).closest('.card');
$card_text = $(this).closest('.card-header').siblings('.card-body').children('.card-text')
if ($(this).attr('data-downloaded') == 'false') {
$(this).attr('data-downloaded', 'true')
getStructure($card.attr('data-parent'), $card_text)
}
else {
}
});