Development #61238
clickable-rows: ne marche pas avec des chemins relatifs
Start date:
28 January 2022
Due date:
% Done:
0%
Estimated time:
Patch proposed:
Yes
Planning:
No
Description
Dans a2, j'ai ce code HTML :
<table class="main clickable-rows" id="ou-table"> <thead> <tr> <th class="name orderable"><a href="?sort=name">libellé</a></th> <th class="orderable slug"><a href="?sort=slug">Identifiant Court</a></th> <th class="default orderable"><a href="?sort=default">Collectivité Par Défaut</a></th> </tr> </thead> <tbody> <tr data-pk="1" class="even"> <td class="name"><a href="/manage/organizational-units/1/">Collectivité par défaut</a></td> <td class="slug">default</td> <td class="default"><span class="true">✔</span></td> </tr> <tr data-pk="2" class="odd"> <td class="name"><a href="/manage/organizational-units/2/">Ma ville</a></td> <td class="slug">ma-ville</td> <td class="default">—</td> </tr> </tbody> </table>
Un click sur la ligne data-pk="1"
hors du lien m'amène sur /manage/organizational-units//manage/organizational-units/1/ au lieu de /manage/organizational-units/1/.
Ce code là :
var data_link = $(this).find('a[href]').attr('href'); if (data_link) { if (data_link.indexOf('http://') == -1 && data_link.indexOf('https://') == -1) { data_link = window.location.pathname + data_link; } if (event.which == 2 || event.ctrlKey) { window.open(data_link, '_blank'); } else { window.location = data_link; } return false; }
devrait être remplacé par le plus simple :
var $anchor = $(this).find('a[href]'); if (anchor.length) { var href = $anchor[0].href; if (event.which == 2 || event.ctrlKey) { window.open(href, '_blank'); } else { window.location = href; } return false; }
si j'en crois https://stackoverflow.com/questions/9910468/window-location-with-relative-url.
Files
Associated revisions
History
Updated by Benjamin Dauvergne over 1 year ago
- File 0001-js-make-.clickable-rows-works-with-relative-href-612.patch 0001-js-make-.clickable-rows-works-with-relative-href-612.patch added
- Status changed from Nouveau to Solution proposée
- Patch proposed changed from No to Yes
Updated by Benjamin Dauvergne over 1 year ago
- Status changed from Solution validée to Résolu (à déployer)
commit 057935195be0707d1b8f7e25ea5b3490ed2b7a41 Author: Benjamin Dauvergne <bdauvergne@entrouvert.com> Date: Fri Jan 28 23:10:07 2022 +0100 js: make .clickable-rows works with relative href (#61238)
Updated by Transition automatique over 1 year ago
- Status changed from Résolu (à déployer) to Solution déployée
js: make .clickable-rows works with relative href (#61238)