Skip to content

Commit 36ea8c7

Browse files
committed
Fix error in exception handling code
1 parent 479cdc2 commit 36ea8c7

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ install:
1111
${BIN}/pip install -e .[clients]
1212
${BIN}/pip install -e .[tests]
1313
${BIN}/pip install pre-commit
14-
#${BIN}/pip install -e ../jupyterlite/py/jupyterlite-core
15-
#${BIN}/pip install -e ../jupyterlite/py/jupyterlite
14+
${BIN}/pip install -e ../jupyterlite/py/jupyterlite-core
15+
${BIN}/pip install -e ../jupyterlite/py/jupyterlite
1616

1717
assets:
1818
rm caterva2/services/static/build/*
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<input type="number" min="0" max="{{ pages - 1 }}" name="i" value="0"
2-
hx-get="{{ href }}" hx-target="#image-div">
2+
hx-get="{{ href }}" hx-target="#image-div" xxhx-swap="innerHTML show:top">
33

4-
<div hx-get="{{ href }}?i=0" hx-trigger="load" id="image-div"></div>
4+
<div hx-get="{{ href }}?i=0" hx-trigger="load" id="image-div" xxhx-preserve></div>

caterva2/services/sub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,7 @@ async def htmx_command(
22752275
try:
22762276
return await cmd.call(request, user, argv, operands, hx_current_url)
22772277
except Exception as exc:
2278-
return htmx_error(request, f'Error in "{command}" command: {exc.detail}')
2278+
return htmx_error(request, f'Error in "{command}" command: {exc}')
22792279

22802280
# If the command is not recognized
22812281
return htmx_error(request, f'Invalid command "{argv[0]}" or expression not found')

caterva2/services/templates/home.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@
106106
//showAlert(ev.detail.error, "danger");
107107
}
108108
})
109+
110+
111+
document.body.addEventListener('htmx:beforeRequest', function(evt) {
112+
console.log('beforeRequest', window.scrollY);
113+
sessionStorage.setItem('scrollPosition', window.scrollY);
114+
});
115+
116+
document.body.addEventListener('htmx:afterSettle', function(evt) {
117+
const scrollPosition = sessionStorage.getItem('scrollPosition');
118+
console.log('afterSwap', window.scrollY, scrollPosition);
119+
if (scrollPosition) {
120+
window.scrollTo(0, scrollPosition);
121+
}
122+
});
109123
</script>
110124

111125
</body>

0 commit comments

Comments
 (0)