Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 7, 2023 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennadel/2549e3c28b7f7a793c2e9ee5a451cc62 to your computer and use it in GitHub Desktop.
Save bennadel/2549e3c28b7f7a793c2e9ee5a451cc62 to your computer and use it in GitHub Desktop.
Styling Submit Buttons During Form Submission With Hotwire And Lucee CFML
<cfscript>
if ( request.isPost ) {
// Sleeping to give us time to observe the busy-state of the submit button.
sleep( 2000 );
location( url = "index.htm?signed=true", addToken = false );
}
</cfscript>
<cfmodule template="./tags/page.cfm">
<cfoutput>
<h2>
Welcome to My Site
</h2>
<form method="post" action="index.htm">
<p>
<textarea
name="message"
placeholder="Sign my guest book :)"
rows="3"
cols="40"
></textarea>
</p>
<p>
<!---
When the form is being submitted, Turbo Drive will automatically
disable THE ACTIVE SUBMISSION BUTTON as well as apply the "submits
with" text if the directive is present on the targeted submission
button. All other submission buttons remain active and unchanged in
their rendering while the form is being processed.
--->
<button
type="submit"
data-turbo-submits-with="Submitting..."
class="submit-button">
Submit
</button>
<button
type="submit"
data-turbo-submits-with="Submitting..."
class="submit-button">
Submit
</button>
</p>
</form>
</cfoutput>
</cfmodule>
.submit-button {
background-color: #ec005a ;
color: #ffffff ;
cursor: pointer ;
&[ disabled ] {
background-color: #212121 ;
cursor: wait ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment