How can I select text inside input when the modal is closed? Below code is working - when I click the input field, alert is coming up and text is selected. On modal hide event alert is shown, but the text is not selected. What is going on here?
JS Code:
// Sellect text
$('.user').on('click', '#name', function(){
$(this).select();
alert(1);
});
$('#myModal').on('hide.bs.modal', function(){
$('.user').find('#name').trigger('click');
});
HTML
<div class="user">
<p>Name
<input type="text" name="name" id="name" value="<?php echo $user->name ?>" readonly="readonly">
</p>
</div>
SOLUTION
I found out that instead of using hide.bs.modal event, I should use hidden.bs.modal event. In that case the script is working.