htmx/test/manual/sse-triggers.html
Ben Pate 93acf88431 Update test cases
- trigger tests working.
- settle tests failing
2021-10-25 21:56:24 -06:00

53 lines
1.6 KiB
HTML

<html>
<head>
<script src="../../src/htmx.js"></script>
<script src="../../src/ext/sse.js"></script>
<script>
htmx.createEventSource = function(url){
return new EventSource(url, {withCredentials:false})
}
</script>
<style>
*{
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
body {
background-color: #eeeeee;
}
.container {
padding: 10px;
border: solid 1px gray;
margin-bottom: 20px;
background-color:white;
}
.bold {
font-weight:bold;
}
</style>
</head>
<body>
<div id="page" hx-ext="sse" sse-url="http://localhost/posts.html?types=event1%2cevent2%2cevent3%2cevent4">
<h3>Testing Triggers</h3>
<div id="first" class="container" hx-get="http://localhost/page/random" hx-trigger="sse:event1">Waiting for Posts in Event1 channel...</div>
<div class="container" hx-get="http://localhost/page/random" hx-trigger="sse:event2">Waiting for Posts in Event2 channel...</div>
<div class="container" hx-get="http://localhost/page/random" hx-trigger="sse:event3">Waiting for Posts in Event3 channel...</div>
<div class="container" hx-get="http://localhost/page/random" hx-trigger="sse:event4">Waiting for Posts in Event4 channel...</div>
</div>
</body>
<!--script>
setInterval(function() {
htmx.trigger("#first", "sse:event1")
/*
var e = new Event("event1")
var id = document.getElementById("first")
id.dispatchEvent(e)
console.log("SENT ***************************",id, e)
*/
}, 500)
</script-->
</html>