Created
March 24, 2023 12:34
-
-
Save bennadel/17436269b6b75b7f3c3c75457a342a15 to your computer and use it in GitHub Desktop.
Trying To Get ChatGPT 4 To Solve My Hotwire Form Submission Problem
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
document.addEventListener("DOMContentLoaded", function() { | |
// Get the form element | |
const form = document.querySelector("form"); | |
// Listen for the Turbo Drive form submission event | |
form.addEventListener("turbo:submit-end", function() { | |
// Scroll the form back into view | |
form.scrollIntoView(); | |
}); | |
}); |
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
document.addEventListener("turbo:submit-end", function(event) { | |
const form = event.target.querySelector("form"); | |
if (form) { | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
} | |
}); |
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
document.addEventListener("DOMContentLoaded", function() { | |
// Get the form element | |
const form = document.querySelector("form"); | |
// Listen for the Turbo Drive form submission event | |
form.addEventListener("turbo:submit-end", function() { | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
}); | |
}); |
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
document.addEventListener("turbo:submit-end", function(event) { | |
const form = event.target; | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
}); |
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
document.addEventListener("turbo:submit-end", function(event) { | |
const form = event.detail.formSubmission.formElement; | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
}); |
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
document.addEventListener("turbo:load", function(event) { | |
const form = event.target.querySelector("form"); | |
if (form) { | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
} | |
}); |
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
document.addEventListener("turbo:load", function(event) { | |
const form = event.target.querySelector("form[data-turbo-permanent]"); | |
if (form) { | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
} | |
}); |
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
document.addEventListener("turbo:load", function(event) { | |
const container = event.target.querySelector("[data-turbo-permanent]"); | |
if (container) { | |
const form = container.querySelector("form"); | |
if (form) { | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
} | |
} | |
}); |
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
document.addEventListener("turbo:submit-end", function(event) { | |
const form = event.target.querySelector("form"); | |
if (form) { | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
} | |
}); |
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
document.addEventListener("turbo:load", function(event) { | |
const form = event.target.querySelector("form"); | |
if (form) { | |
// Scroll the form back into view after a short delay | |
setTimeout(function() { | |
form.scrollIntoView(); | |
}, 0); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment