A lot works!
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg modal-dialog-scrollable" role="document">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title text-center" id="details-title">Modal title</h5>
|
||||
@@ -9,7 +9,8 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="details-intro"></div>
|
||||
<div id="details-intro" class="font-weight-bold"></div>
|
||||
<div id="details-images"></div>
|
||||
<div id="details-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -19,20 +20,25 @@
|
||||
<script>
|
||||
$('#detailModal').on('show.bs.modal', function (event) {
|
||||
let card = $(event.relatedTarget); // Button that triggered the modal
|
||||
{#let name = card.data('name'); // Extract info from data-* attributes#}
|
||||
let post_id = card.data('post_id');
|
||||
|
||||
$.post(`/api/post/${post_id}`, data => {
|
||||
if (!data.success) {
|
||||
console.error("No data for post");
|
||||
return;
|
||||
}
|
||||
let modal = $(this);
|
||||
console.log(data);
|
||||
modal.find('#details-title').text(data.post.title);
|
||||
modal.find('#details-intro').text(data.post.intro);
|
||||
modal.find('#details-description').text(data.post.description);
|
||||
|
||||
let post = data.post;
|
||||
console.log(post);
|
||||
|
||||
$('#details-title').text(post.title);
|
||||
$('#details-intro').text(post.intro);
|
||||
$('#details-description').text(post.description);
|
||||
|
||||
$('#details-images').text('');
|
||||
post.images.forEach(image => {
|
||||
$('#details-images').append(`<img src=${image}>`)
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
.on('shown.bs.modal', function () {
|
||||
$('#detailModal').scrollTop(0);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user