Search code examples
htmlbootstrap-modalbootstrap-5

Bootstrap modal not showing with ID > 1000


As the title said, i have a table with hundred of row, i assign a td> tag with a modal but i noticed that the modal did not show up if my id is > 1000. This is how i setup my in data target in td> :

<td data-toggle="modal" data-target="#edit-{{data.pk}}">{{data.prk.rekap_user_induk}}</td>

and in modal :

<div class="modal fade" id="edit-{{data.pk}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">

for now I am converting my pk to hex (and it works for now) but i realized that soon my pk will past the 1000 in base 16.


Solution

  • That's because Django's l10n will prettify numbers by using thousand seperators (causing invalid ids and targets. Using {{data.pk|safe}} will output your numbers as text without thousand seperators.