Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#17373 closed Bug (fixed)

jQuery forward compatibility: TabularInline with extra = 0: "Add another" wraps in <div> instead of <tr> inside of <table>

Reported by: jpic Owned by: nobody
Component: contrib.admin Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

To reproduce the bug, set extra = 0 in a TabularInline. Then open the admin page with the inline table, the "Add another" link is in a tr/td inside the table. Click "Add another" and it will add a row and wrap the "Add another" link inside a <div> instead of tr/td.

It is semantically wrong (a <div> may not have <table> for parent) and displays wrong ("Add another X" shouldn't wordwrap).

To fix the bug, change in https://code.djangoproject.com/browser/django/trunk/django/contrib/admin/static/admin/js/inlines.js#L44:

$(this).attr("tagName") == "TR"

Into:

$(this).is('tr')

FTR is there a better way than this command to enable non-compressed admin js ?

ln -Lfn ../env/lib/python2.7/site-packages/django/contrib/admin/media/js/inlines.js static/admin/js/inlines.min.js

Change History (5)

comment:1 Changed 3 years ago by bpeschier

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

Can you provide more information about how to reproduce the bug?

I tested it with 1.3.1 and trunk and cannot reproduce it: it adds the correct rows/cells and does not word-wrap.

comment:2 Changed 3 years ago by jpic

I'm using jQuery 1.6.2 and that's probably part of the problem. I don't know what's Django's politics about jQuery version but the proposed change should be both forward and backward compatible.

comment:3 Changed 3 years ago by jpic

  • Resolution needsinfo deleted
  • Status changed from closed to reopened
  • Summary changed from TabularInline with extra = 0: "Add another" wraps in <div> instead of <tr> inside of <table> to jQuery forward compatibility: TabularInline with extra = 0: "Add another" wraps in <div> instead of <tr> inside of <table>

comment:4 Changed 3 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from reopened to closed

r16967 should isolate Django's version of jQuery (used by the admin) from any other version (one you would load in a custom template).

So I believe this bug is fixed in trunk (or 1.4 alpha). Please reopen if it still occurs.

comment:5 Changed 3 years ago by anonymous

"jQuery version being isolated" is indeed an excuse for "not improving the javascript shipped by Django" ?

But what's the reason ? No time ?

Note: See TracTickets for help on using tickets.
Back to Top