-
-
Save rayonx/f0d5a8c061b5dc1c2c876370839e4273 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