Opened 4 years ago

Closed 4 years ago

#19598 closed Bug (fixed)

Bug in inlines.js

Reported by: rj@… Owned by: nobody
Component: contrib.admin Version: 1.4
Severity: Normal Keywords: javascript, inlines.js
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes


I just noticed a small bug in inlines.js. In the part where the "addButton" is included, the following check is used:

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

This check doesn't work as expected however. The attr-method reads an attribute. "tagName" isn't an attribute. This check should be:

if ($"tr")) {

Due to this bug, the "Add another ..." link gets positioned weirdly when using a TabularInline.

Change History (9)

comment:1 Changed 4 years ago by Mark Lavin

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

The admin uses jQuery 1.4.2 and prior to jQuery 1.6 you could retrieve the tagName with attr. In jQuery 1.6+ you have to use prop This needs to be changed when the jQuery version is upgraded but I don't see why this would be a bug using stock jQuery in the admin.

comment:2 Changed 4 years ago by rj@…

I am not very familiar with jquery. All I know is that I saw the Add Another link behave weirdly, and this change solved it. The fix I proposed is consistent with how the rest of the file checks for the tagname.

comment:3 Changed 4 years ago by chris cauley

You could just break out of jQuery, then it would be version independent.

if ($this.0.tagName.toUpperCase()=="TR") {

comment:4 Changed 4 years ago by Bas Peschier

Closed #19623 as a duplicate.

comment:5 Changed 4 years ago by Bas Peschier

The bundled jQuery handles the attr-call correctly, and though it is not the most up-to-date code there is, it should work (checked against a stock 1.4 admin).

comment:6 Changed 4 years ago by Julien Phalip

A question for the OP: could you explain explain how to reproduce this problem?

Django's JS code solely relies on the bundled version of jQuery, so I don't see how a separate version of jQuery could cause this type of conflict.

Version 0, edited 4 years ago by Julien Phalip (next)

comment:7 Changed 4 years ago by Claude Paroz

Resolution: needsinfo
Status: newclosed

comment:8 Changed 4 years ago by Claude Paroz

Resolution: needsinfo
Status: closednew
Triage Stage: UnreviewedAccepted

Now that we have jQuery 1.9.1, attr("tagName") should be prop("tagName")

comment:9 Changed 4 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In cb5545ea2d747e2457221a03e985ef9b4a79ee2e:

Fixed #19598 -- Fixed jQuery tagName retrieving

Thanks rj at for the report.

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