Created
May 6, 2023 19:26
-
-
Save edofic/7c6fc369ef960315422914e946f4854b to your computer and use it in GitHub Desktop.
htmx + mock requests = SPA?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello Page</title> | |
<script src="https://unpkg.com/[email protected]"></script> | |
<script src="https://unpkg.com/[email protected]/index.js"></script> | |
<script language="javascript"> | |
MockRequests.setDynamicMockUrlResponse('/ui/button', | |
{ | |
dynamicResponseModFn: | |
function (request, response, parameters) { | |
console.log("A mock request was made: ", request, response, parameters) | |
return "hello"; // hardcoded here but full request is available for dynamically generating | |
}, | |
usePathnameForAllQueries: true | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Hello</h1> | |
<button hx-get="/ui/button" hx-swap="afterend">Load</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment