<p></p>
<p><b>@tomhughes</b> commented on this pull request.</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5116#discussion_r1730392259">app/assets/javascripts/richtext.js</a>:</p>
<pre style='color:#555'>> @@ -1,53 +1,61 @@
-$(document).ready(function () {
- /*
- * When the text in an edit pane is changed, clear the contents of
- * the associated preview pne so that it will be regenerated when
- * the user next switches to it.
- */
- $(".richtext_container textarea").change(function () {
- var container = $(this).closest(".richtext_container");
+(function () {
+ $(document).ready(function () {
+ /*
</pre>
<p dir="auto">Do we actually need this? The only things happening inside it are installing handlers on document and window which should be safe without waiting for the page to be ready?</p>
<hr>
<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5116#discussion_r1730392482">app/assets/javascripts/richtext.js</a>:</p>
<pre style='color:#555'>> });
- /*
- * Install a handler to switch to preview mode
- */
- $(".richtext_container button[data-bs-target$='_preview']").on("show.bs.tab", function () {
- var container = $(this).closest(".richtext_container");
- var editor = container.find("textarea");
- var preview = container.find(".tab-pane[id$='_preview']");
+ $(document).on("turbo:load", function () {
+ /*
+ * When the text in an edit pane is changed, clear the contents of
+ * the associated preview pne so that it will be regenerated when
+ * the user next switches to it.
+ */
+ $(".richtext_container textarea").change(function () {
</pre>
<p dir="auto">Is it safe to do these on <code class="notranslate">turbo:load</code> or might we get handlers installed twice on the same object if a partial load occurs? Is there any reason not to register these on document with event delegation?</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/5116#pullrequestreview-2259337639">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMBXFDELOIY4P6L4LLZTICARAVCNFSM6AAAAABNBVGYGCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDENJZGMZTONRTHE">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLMXIE4JRLKQEB53FXLZTICARA5CNFSM6AAAAABNBVGYGCWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUGVLA2O.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/5116/review/2259337639</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/5116#pullrequestreview-2259337639",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/5116#pullrequestreview-2259337639",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>