My teacher gave me schoolwork on how to pass data table to modal class in Django. I just want to display the profile click in table to modal. Any help can make me grateful thanks.I'm just a newbie here and since it was almost 2 weeks I've been starting learning django Below is my currently code and it's not working.
accounts.html
<table style="width: 100%;" id="example" class="table table-hover table-striped table-bordered">
<thead>
<tr>
<th>Action</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
<th>Username</th>
<th>Date joined</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div id="modal-div"></div
views.py
def edit(request,id):
user = auth.authenticate(id=id)
return render(request, 'accounts.html',{'user_information':user,'successful_submit': True})
js
<script >
var modalDiv = $("#modal-div");
$(".open-modal").on("click", function() {
$.ajax({
url: $(this).attr("data-url"),
success: function(data) {
modalDiv.html(data);
$("#exampleModal").modal();
}
});
});
</script>
Aucun commentaire:
Enregistrer un commentaire