Skip to content

Commit

Permalink
Use hx-push-url where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Oct 21, 2023
1 parent b35097d commit af3adbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/templates/fragments/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<li th:fragment="menuItem (link,active,title,glyph,text,target)" th:class="nav-item"
_="on htmx:afterOnLoad take .active for event.target">
<a th:class="${active==menu ? 'nav-link active' : 'nav-link'}" th:href="@{__${link}__}" th:title="${title}"
hx:get="@{__${link}__}" hx:target="${target}" hx:push-url="@{__${link}__}">
hx:get="@{__${link}__}" hx:target="${target}" hx-push-url="true">
<span th:class="'fa fa-'+${glyph}" class="fa fa-home"></span>
<span th:text="${text}">Template</span>
</a>
Expand Down
25 changes: 6 additions & 19 deletions src/main/resources/templates/fragments/owners.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2>Find Owners</h2>
</div>

<a class="btn btn-primary" hx:get="@{/owners/new}" hx-swap="innerHTML" hx-target="#block-content"
hx:push-url="@{/owners/new}" th:href="@{/owners/new}">Add Owner</a>
hx-push-url="true" th:href="@{/owners/new}">Add Owner</a>

</form>
</div>
Expand All @@ -47,7 +47,7 @@ <h2>Owners</h2>
<tr th:each="owner : ${listOwners}">
<td>
<a th:href="@{/owners/__${owner.id}__}" th:text="${owner.firstName + ' ' + owner.lastName}"
hx:get="@{/owners/__${owner.id}__}" hx:push-url="@{/owners/__${owner.id}__}" hx-target="#block-content"/></a>
hx:get="@{/owners/__${owner.id}__}" hx-push-url="true" hx-target="#block-content"/></a>
</td>
<td th:text="${owner.address}"/>
<td th:text="${owner.city}"/>
Expand Down Expand Up @@ -83,17 +83,10 @@ <h2>Owner Information</h2>
</tr>
</table>

<<<<<<< HEAD
<a hx:get="@{__${owner.id}__/edit}" hx-target="#block-content" th:href="@{__${owner.id}__/edit}"
<a hx:get="@{__${owner.id}__/edit}" hx-push-url="true" hx-target="#block-content" th:href="@{__${owner.id}__/edit}"
class="btn btn-primary">Edit
Owner</a>
<a hx:get="@{__${owner.id}__/pets/new}" th:href="@{__${owner.id}__/pets/new}" hx-target="#block-content" class="btn btn-primary">Add
=======
<a hx:get="@{__${owner.id}__/edit}" hx:push-url="@{__${owner.id}__/edit}" hx-target="#block-content" th:href="@{__${owner.id}__/edit}"
class="btn btn-primary">Edit
Owner</a>
<a hx:get="@{__${owner.id}__/pets/new}" hx:push-url="@{__${owner.id}__/pets/new}" th:href="@{__${owner.id}__/pets/new}" hx-target="#block-content" class="btn btn-primary">Add
>>>>>>> 9a4ee11 (Remove unnecessary servlet response manipulations)
<a hx:get="@{__${owner.id}__/pets/new}" hx-push-url="true" th:href="@{__${owner.id}__/pets/new}" hx-target="#block-content" class="btn btn-primary">Add
New Pet</a>
</div>

Expand Down Expand Up @@ -129,19 +122,13 @@ <h2>Pets and Visits</h2>
</tr>
<tr>
<td><a th:href="@{__${owner.id}__/pets/__${pet.id}__/edit}"
<<<<<<< HEAD
hx-get="@{__${owner.id}__/pets/__${pet.id}__/edit}" hx-target="#block-content">Edit Pet</a></td>
<td><a th:href="@{__${owner.id}__/pets/__${pet.id}__/visits/new}"
hx:get="@{__${owner.id}__/pets/__${pet.id}__/visits/new}" hx-target="#block-content">Add Visit</a></td>
=======
hx:get="@{__${owner.id}__/pets/__${pet.id}__/edit}"
hx:push-url="@{__${owner.id}__/pets/__${pet.id}__/edit}"
hx-push-url="true"
hx-target="#block-content">Edit Pet</a></td>
<td><a th:href="@{__${owner.id}__/pets/__${pet.id}__/visits/new}"
hx:get="@{__${owner.id}__/pets/__${pet.id}__/visits/new}"
hx:push-url="@{__${owner.id}__/pets/__${pet.id}__/visits/new}"
hx-push-url="true"
hx-target="#block-content">Add Visit</a></td>
>>>>>>> 9a4ee11 (Remove unnecessary servlet response manipulations)
</tr>
</table>
</td>
Expand Down

0 comments on commit af3adbb

Please sign in to comment.