In my project, I am utilizing Laravel and AJAX. Inside the index.blade.php file, I have the following code:
<a onclick="addForm()" class="btn btn-success " style="float:right;">Tambah</a>
Additionally, I have the following script:
<script type="text/javascript">
function addForm(){
save_method = "add" ;
$('input[name=method]').val('POST') ;
$('#myModal').modal('show') ;
$('#myModal form')[0].reset() ;
$('.modal-title').text('Tambah Kategori') ;
}
</script>
Now, I want to call the modal from another file called form.blade.php, which is located in the same folder as index.blade.php. Here is an excerpt from my form file:
<div class="modal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<form class="form-horizontal" data-toggle="validator" method="POST">
{{ csrf_field() }} {{ method_field('POST') }}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h3 class="modal-title"></h3>
</div>
<div class="modal-body">
<input type="hidden" name="id" id="id">
<div class="form-group">
<label for="nama" class="col-md-3 control-label">Nama</label>
<div class="col-md-6">
<input type="text" id="nama" class="form-control" name="nama" autofocus required>
<span class="help-block with-errors"></span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-save">Simpan</button>
<button type="button" class="btn btn-warning" data-dismiss="modal">Batal</button>
</div>
</form>
</div>
</div>
However, I am encountering an issue where my modal is not displaying. Can anyone provide insights on why this might be happening?