I have jQuery code which is never executed. When I'm trying the same code in the browser console it works, so I don't understand why my code is never executed.
HTML CODE :
<div id="ans">
<label>{$valeur}</label>
<div class="radio">
{foreach $reponse as $ligne}
<input type="radio" name="answers" id="answer_{$ligne@iteration}" value="{$ligne@iteration}"/><label for="answer_{$ligne@iteration}">$ligne</label><br />
{/foreach}
</div>
</div>
Update :
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function(){
$.post(ajax_path+"bla.php", {} , function(response) {
$('#quest').html(response);
$('#quest').collapse("show");
})
.fail(function(jqXHR, textStatus, errorThrown) {
{/literal}
toastr.error(__['Error'], __['Error']);
{literal}
});
}, 50);
$('input[name=answers]').on('change', function () {
$(this).closest("form").submit();
});
});