Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / app / assets / javascripts / link_to_remote.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 $.rails.href = function(element) {
6     if (element.is('a')) {
7         // data-remote=true links must put their remote targets in
8         // data-remote-href="..." instead of href="...".  This helps
9         // us avoid accidentally using the same href="..." in both the
10         // remote (Rails UJS) and non-remote (native browser) handlers
11         // -- which differ greatly in how they use that value -- and
12         // forgetting to test any non-remote cases like "open in new
13         // tab". If you really want copy-link-address/open-in-new-tab
14         // to work on a data-remote=true link, supply the
15         // copy-and-pastable URI in href in addition to the AJAX URI
16         // in data-remote-href.
17         //
18         // (Currently, the only places we make any remote links are
19         // link_to() in ApplicationHelper, which renames href="..." to
20         // data-remote-href="...", and select_modal, which builds a
21         // data-remote=true link on the client side.)
22         return element.data('remote-href');
23     } else {
24         // Normal rails-ujs behavior.
25         return element.attr('href');
26     }
27 }