Opened 12 years ago
Closed 12 years ago
#19598 closed Bug (fixed)
Bug in inlines.js
Reported by: | 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 , 12 years ago
comment:2 by , 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 , 12 years ago
You could just break out of jQuery, then it would be version independent.
if ($this.0.tagName.toUpperCase()=="TR") {
comment:5 by , 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 , 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.
comment:7 by , 12 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:8 by , 12 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → new |
Triage Stage: | Unreviewed → Accepted |
Now that we have jQuery 1.9.1, attr("tagName")
should be prop("tagName")
comment:9 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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 useprop
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.