I can open my modal with script (id matches), but function on show does not get triggered. I just want to find out why can't I trigger that function? Is my js syntax wrong? Should I have it all in "document ready" function?.
MAIN
<body>
<?php
require 'connect.php';
$r = $db->getReference('guests');
$ref = $r->getChild($dat)->getChild($id);
$value = $ref->getValue();
$json = json_encode($value);
require 'model.html';
?>
</body>
<script>
$(document).ready(function(){
$('#modalas').modal('show');
var obj = JSON.parse('<?= $json; ?>');
console.log(obj);
var vardass = obj.vardas;
$("#modalas").on("shown.bs.modal", function () {
console.log(vardass)
var modal = $(this)
$("#post_form")[0].reset();
modal.find('.modal-title').text(vardass)
document.getElementById("NameInput").value = obj.vardas;
document.getElementById("LastInput").value = obj.pavarde;
})
})
</script>