gorgeous-ghost-95789
04/17/2021, 4:52 PMmillions-diamond-89785
04/17/2021, 4:52 PMmillions-diamond-89785
04/17/2021, 4:52 PMgorgeous-ghost-95789
04/17/2021, 4:53 PMgorgeous-ghost-95789
04/17/2021, 4:55 PM<button hx-get="/my-server" hx-target="#somewhere">Go</button> -- I can't use Javascript to change the hx-get element of that button. htmx has already processed it and put its working data in another place.gorgeous-ghost-95789
04/17/2021, 4:56 PMmillions-diamond-89785
04/17/2021, 5:02 PMmillions-diamond-89785
04/17/2021, 5:08 PMmysterious-toddler-20573
04/17/2021, 6:15 PMmysterious-toddler-20573
04/17/2021, 6:15 PMuser
04/17/2021, 7:01 PMuser
04/17/2021, 7:01 PMgorgeous-ghost-95789
04/17/2021, 7:43 PMgorgeous-ghost-95789
04/17/2021, 7:44 PMuser
04/17/2021, 7:44 PMuser
04/17/2021, 7:45 PMgorgeous-ghost-95789
04/17/2021, 7:45 PMhtml
<script src="https://unpkg.com/htmx.org"></script>
<div hx-get="style.html" hx-trigger="load"></div>
style.html
html
<link rel="stylesheet" href="test.css" />
<style>
.red {color:red;}
</style>
<h1>This is the Style</h1>
<b class="red">This is Red</b>
<b class="blue">This is Blue</b>gorgeous-ghost-95789
04/17/2021, 7:45 PMgorgeous-ghost-95789
04/17/2021, 7:46 PMuser
04/17/2021, 7:46 PMlet css = document.querySelector('#darkMode');
function changeTheme() {
if (css.getAttribute('href') === '/static/css/0x-light.css') {
document.cookie = "theme=dark; expires=Thu, 01 Jan 2100 00:00:00 UTC;";
css.setAttribute('href', '/static/css/0x-dark.css');
} else if (css.getAttribute('href') === '/static/css/0x-dark.css') {
document.cookie = "theme=light; expires=Thu, 01 Jan 2100 00:00:00 UTC;";
css.setAttribute('href', '/static/css/0x-light.css');
}
}user
04/17/2021, 7:46 PMgorgeous-ghost-95789
04/17/2021, 7:47 PMgorgeous-ghost-95789
04/17/2021, 7:51 PMmysterious-toddler-20573
04/17/2021, 7:57 PMmysterious-toddler-20573
04/17/2021, 7:57 PMgorgeous-ghost-95789
04/17/2021, 7:58 PMuser
04/17/2021, 8:00 PMuser
04/17/2021, 8:00 PMgorgeous-ghost-95789
04/17/2021, 8:03 PMon click from #themeToggler
toggle [@href] between "/static/css/0x-light.css" and "/static/css/0x-dark.css"
set cookie "theme" to [@href] expiring 1 year from now
end
š also added a shameless plug for my date/time library request. Never waste an opportunity, right?mysterious-toddler-20573
04/17/2021, 8:05 PMdef changeTheme()
if #darkMode@href is '/static/css/0x-light.css'
set the document's cookie to "theme=dark; expires=Thu, 01 Jan 2100 00:00:00 UTC;"
set #darkMode@href to '/static/css/0x-dark.css'
else
set the document's cookie to "theme=light; expires=Thu, 01 Jan 2100 00:00:00 UTC;"
set #darkMode@href to '/static/css/0x-light.css'