Skip to content

Commit

Permalink
Use javascript to place content when it arrives
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Sep 29, 2017
1 parent b657ad9 commit 56b971c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<artifactId>thymeleaf-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
logging.level.org.thymeleaf.spring5=TRACE
spring.thymeleaf.reactive.max-chunk-size=8192
spring.thymeleaf.cache=false
44 changes: 25 additions & 19 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@
<html>
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>MatchDay: All matches</title>
<title>Stuff</title>

<link data-th-href="@{/webjars/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
<link data-th-href="@{/webjars/bootstrap/css/bootstrap.min.css}"
rel="stylesheet">
<script data-th-src="@{/webjars/jquery/jquery.min.js}"></script>

</head>
<body>

<div class="container">

<div class="row">
<table id="allMatches" class="table table-striped">
<body>
<tr class="result" data-th-each="greeting : ${greetings}">
<td class="ID">[[${greeting.id}]]</td>
<td class="Message">[[${greeting.msg}]]</td>
</tr>
</body>
</table>
</div>

<div class="container">
<h2>Before</h2>
<div class="row">
<table id="stuff" class="table table-striped">
<tbody id="greetings">
</tbody>
</table>
</div>

<p>After</p>
</div>

<th:block data-th-each="greeting,status: ${greetings}">
<script data-th-id="|foo-${status.index}|" type="text/html"
data-th-include="~{message}">
</script>
<script>
$("#greetings").append($("#foo-[[${status.index}]]").html())
</script>
</th:block>
</body>
</html>
4 changes: 4 additions & 0 deletions src/main/resources/templates/message.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<tr class="result">
<td class="ID">[[${greeting.id}]]</td>
<td class="Message">[[${greeting.msg}]]</td>
</tr>

0 comments on commit 56b971c

Please sign in to comment.