It should be something like
<script>
$(document).ready(function() {
let myModal = $('#reminderModal');
if (myModal.html() != '') { # or may modal.html().length != 0
myModal.modal('show');
}
})
</script>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have this Modal:
<div id="reminderModal" class="modal fade">
<div class="modal-dialog" >
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="reminderModalLabel">Receipt Verification</h4>
</div>
<div class="modal-body text-center pagination-centered">
@foreach ($quot_one as $key_1)
<h5>Please verify the receipt of the quotation of <b>{{ $key_1->name }}</b> sent on
{{ $key_1->date_of_sending_inquiry }} </h5>
<p><a href="{{ route('quot.editquot', $key_1->quotId) }}" class="btn btn-dark "
type="button">Verify Receipt</a></p>
@endforeach
</div>
</div>
</div>
</div>
It displays on the page load called by jQuery:
<script>
$(document).ready(function() {
$("#reminderModal").modal('show');
})
</script>
$quot_one are database entries that meet a certain condition where a value is 0. When that value is turned to 1 for every entry, the Modal will be empty body wise.
Is it possible to make that modal only appears if it has a body? And if so, how to do it? (I am very new to jQuery so any help would be appreciated)
@littledaggers there you go : https://codepen.io/aquel/pen/yLKNbJW
It works.
PS: this is NOT the best way according to me. I think it would be best to set an attribute to the modal for instance
<div id="reminderModal" class="modal fade" data-show="true">
Please or to participate in this conversation.