Projet

Général

Profil

Development #61238

clickable-rows: ne marche pas avec des chemins relatifs

Ajouté par Benjamin Dauvergne il y a environ 2 ans. Mis à jour il y a environ 2 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
-
Début:
28 janvier 2022
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

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.


Fichiers

Révisions associées

Révision 05793519 (diff)
Ajouté par Benjamin Dauvergne il y a environ 2 ans

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

Historique

#1

Mis à jour par Benjamin Dauvergne il y a environ 2 ans

  • Assigné à mis à Benjamin Dauvergne
#2

Mis à jour par Benjamin Dauvergne il y a environ 2 ans

#4

Mis à jour par Benjamin Dauvergne il y a environ 2 ans

  • Tags mis à relecture-facile
#5

Mis à jour par Thomas Jund (congés, retour le 29/04) il y a environ 2 ans

  • Statut changé de Solution proposée à Solution validée
#6

Mis à jour par Benjamin Dauvergne il y a environ 2 ans

  • Statut changé de Solution validée à 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

Mis à jour par Transition automatique il y a environ 2 ans

  • Statut changé de Résolu (à déployer) à Solution déployée
#8

Mis à jour par Transition automatique il y a environ 2 ans

Automatic expiration

Formats disponibles : Atom PDF