[openstreetmap/openstreetmap-website] Adapt richtext javascript to Turbo (PR #5116)

Tom Hughes notifications at github.com
Sun Sep 8 14:57:33 UTC 2024


@tomhughes commented on this pull request.



>    });
 
-  /*
-   * 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 () {

Hmm that's unfortunate... Maybe we should leave it in `turbo:load` then? But it would need to be converted to a named function so that it won't get installed more than once on the same element.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5116#discussion_r1749259864
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5116/review/2288553168 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240908/d252edbd/attachment-0001.htm>


More information about the rails-dev mailing list