Skip to content

Commit

Permalink
fixed bug for uid
Browse files Browse the repository at this point in the history
  • Loading branch information
paqstd-dev committed Nov 26, 2023
1 parent 7730018 commit e666d7d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
18 changes: 10 additions & 8 deletions example/posts/templates/posts/all.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{% load suspense %}

{% extends "base.html" %}

{% load suspense %}

{% block content %}
<aside class="py-8 lg:py-24 bg-gray-50 dark:bg-gray-800">
<div class="px-4 mx-auto max-w-screen-xl">
<h2 class="mb-8 text-2xl font-bold text-gray-900 dark:text-white">
Related posts
</h2>

<div class="grid gap-12 sm:grid-cols-2 lg:grid-cols-4">
{% suspense %}
{% fallback %}
{% suspense %}
{% fallback %}
<div class="grid gap-12 sm:grid-cols-2 lg:grid-cols-4">
<div role="status" class="max-w-sm animate-pulse">
<div class="h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"></div>
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[330px] mb-2.5"></div>
Expand All @@ -32,8 +32,10 @@ <h2 class="mb-8 text-2xl font-bold text-gray-900 dark:text-white">
<div class="h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[300px] mb-2.5"></div>
<span class="sr-only">Loading...</span>
</div>
{% endfallback %}
</div>
{% endfallback %}

<div class="grid gap-12 sm:grid-cols-2 lg:grid-cols-4">
{% for post in posts %}
<article class="max-w-xs">
<h2 class="mb-2 text-xl font-bold leading-tight text-gray-900 dark:text-white">
Expand All @@ -44,8 +46,8 @@ <h2 class="mb-2 text-xl font-bold leading-tight text-gray-900 dark:text-white">
</a>
</article>
{% endfor %}
{% endsuspense %}
</div>
</div>
{% endsuspense %}
</div>
</aside>
{% endblock %}
2 changes: 1 addition & 1 deletion example/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
asgiref==3.7.2
Django==4.2.7
django-suspense==0.0.1
django-suspense==1.0.1
sqlparse==0.4.4
6 changes: 5 additions & 1 deletion suspense/templates/suspense/loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
{{ loading }}

<script>
fetch('{% url "django_suspense_loader" %}', {headers: {SUSPENSE_UID: uid}}).then(async (data) => {
fetch('{% url "django_suspense_loader" %}', {
headers: {
SUSPENSE_UID: "{{uid}}"
}
}).then(async (data) => {
document.getElementById('suspense-loader-{{ uid }}').innerHTML = await data.text();
})
</script>
Expand Down

0 comments on commit e666d7d

Please sign in to comment.