-
Maybe I'm just dumb and there is a super easy solution to this. Simple API with a URI "thing/number" Is there a way to do that with htmx? Changing now the API to accept params would require major PITA. I think the hx-append attribute idea would be a super powerful client addition. help pls? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey, I'm not sure to understand your usecase, but could the |
Beta Was this translation helpful? Give feedback.
-
Maybe this related code can help: <!DOCTYPE html>
<html lang="en">
<head>
<script src="https://unpkg.com/htmx.org"></script>
<script>
function updateAction() {
var query = document.getElementById('query').value;
var form = document.getElementById('searchForm');
form.setAttribute('hx-get', '/search/' + encodeURIComponent(query));
}
</script>
</head>
<body>
<form id="searchForm" method="get" hx-get="/search" hx-target="#result" hx-trigger="keyup changed delay:500ms">
<input type="text" id="query" name="query" oninput="updateAction()">
<input type="submit" value="Search">
</form>
<div id="result">
<!-- Search results will be loaded here -->
</div>
</body>
</html> |
Beta Was this translation helpful? Give feedback.
Hey, I'm not sure to understand your usecase, but could the
path-params
extension fit your needs here?Hope it helps!