Opened 12 years ago

Closed 12 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

Description

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 ($this.is("tr")) {

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

Change History (9)

comment:1 by Mark Lavin, 12 years ago

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 http://api.jquery.com/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 by rj@…, 12 years ago

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 by chris cauley, 12 years ago

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

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

comment:4 by Bas Peschier, 12 years ago

Closed #19623 as a duplicate.

comment:5 by Bas Peschier, 12 years ago

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 by Julien Phalip, 12 years ago

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 12 years ago by Julien Phalip (next)

comment:7 by Claude Paroz, 12 years ago

Resolution: needsinfo
Status: newclosed

comment:8 by Claude Paroz, 12 years ago

Resolution: needsinfo
Status: closednew
Triage Stage: UnreviewedAccepted

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

comment:9 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In cb5545ea2d747e2457221a03e985ef9b4a79ee2e:

Fixed #19598 -- Fixed jQuery tagName retrieving

Thanks rj at rudiculous.net for the report.

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