Progress
This commit is contained in:
@@ -5,15 +5,18 @@
|
||||
{% block main %}
|
||||
<main class="container">
|
||||
<div class="row">
|
||||
{% for i in range(count) %}
|
||||
{% for post in posts %}
|
||||
<div class="col-lg-3 col-md-4 col-6">
|
||||
<a data-toggle="modal" data-target="#detailModal" data-name="{{ i }}">
|
||||
<a data-toggle="modal"
|
||||
data-target="#detailModal"
|
||||
data-post_id="{{ post.id }}"
|
||||
>
|
||||
<div class="card border-light">
|
||||
<img class="card-img" src="https://placeimg.com/400/400/any" alt="random image">
|
||||
|
||||
<div class="card-img-overlay d-flex align-items-center justify-content-center">
|
||||
<div class="card-title-bg bg-dark w-100 d-flex align-items-center justify-content-center">
|
||||
<h5 class="card-text text-light">{{ i }}</h5>
|
||||
<h5 class="card-text text-light">{{ post.title }}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
<div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-dialog modal-lg modal-dialog-scrollable" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title text-center" id="exampleModalLabel">Modal title</h5>
|
||||
<h5 class="modal-title text-center" id="details-title">Modal title</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
||||
</p>
|
||||
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
|
||||
</p>
|
||||
<div id="details-intro"></div>
|
||||
<div id="details-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -21,11 +19,20 @@
|
||||
<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
|
||||
// If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
|
||||
// Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
|
||||
let modal = $(this);
|
||||
modal.find('.modal-title').text(name);
|
||||
{#modal.find('.modal-body input').val(recipient)#}
|
||||
{#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);
|
||||
|
||||
});
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user