fix(locations): Remove/Restore buttons broken by quote collision in onclick
The buttons used inline `onclick="...({{ name | tojson }})"`, which
emits the location name as a JSON-quoted string with double quotes —
those double quotes collide with the onclick attribute's own double
quotes, terminating the attribute early. Result: the browser parses
the attribute as broken HTML and the click handler never fires.
Switched both Remove and Restore to the data-attribute pattern the
Edit button already uses (data-loc-id / data-loc-name read via
this.dataset in the onclick). Robust against any character in the
location name.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -53,7 +53,9 @@
|
|||||||
class="text-xs px-3 py-1 rounded-full bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300">
|
class="text-xs px-3 py-1 rounded-full bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300">
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
<button onclick="openRemoveLocationModal('{{ item.location.id }}', {{ item.location.name | tojson }})"
|
<button data-loc-id="{{ item.location.id }}"
|
||||||
|
data-loc-name="{{ item.location.name | e }}"
|
||||||
|
onclick="openRemoveLocationModal(this.dataset.locId, this.dataset.locName)"
|
||||||
class="text-xs px-3 py-1 rounded-full bg-amber-50 text-amber-700 dark:bg-amber-900/20 dark:text-amber-300 hover:bg-amber-100"
|
class="text-xs px-3 py-1 rounded-full bg-amber-50 text-amber-700 dark:bg-amber-900/20 dark:text-amber-300 hover:bg-amber-100"
|
||||||
title="Mark as no longer actively monitored — preserves historical events">
|
title="Mark as no longer actively monitored — preserves historical events">
|
||||||
Remove
|
Remove
|
||||||
@@ -122,7 +124,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<button onclick="restoreLocation('{{ item.location.id }}', {{ item.location.name | tojson }})"
|
<button data-loc-id="{{ item.location.id }}"
|
||||||
|
data-loc-name="{{ item.location.name | e }}"
|
||||||
|
onclick="restoreLocation(this.dataset.locId, this.dataset.locName)"
|
||||||
class="text-xs px-3 py-1 rounded-full bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300 hover:bg-green-200"
|
class="text-xs px-3 py-1 rounded-full bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300 hover:bg-green-200"
|
||||||
title="Restore to active monitoring">
|
title="Restore to active monitoring">
|
||||||
Restore
|
Restore
|
||||||
|
|||||||
Reference in New Issue
Block a user