Project

General

Profile

Development #61238

clickable-rows: ne marche pas avec des chemins relatifs

Added by Benjamin Dauvergne about 1 year ago. Updated 12 months ago.

Status:
Fermé
Priority:
Normal
Target version:
-
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

Revision 05793519 (diff)
Added by Benjamin Dauvergne 12 months ago

js: make .clickable-rows works with relative href (#61238)

History

#1

Updated by Benjamin Dauvergne about 1 year ago

  • Assignee set to Benjamin Dauvergne
#2

Updated by Benjamin Dauvergne about 1 year ago

#4

Updated by Benjamin Dauvergne about 1 year ago

  • Tags set to relecture-facile
#5

Updated by Thomas Jund about 1 year ago

  • Status changed from Solution proposée to Solution validée
#6

Updated by Benjamin Dauvergne 12 months 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)
#7

Updated by Transition automatique 12 months ago

  • Status changed from Résolu (à déployer) to Solution déployée
#8

Updated by Transition automatique 10 months ago

Automatic expiration

Also available in: Atom PDF