Code

#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.

Attachments (0)

Change History (9)

comment:1 Changed 15 months ago by mlavin

  • 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 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 Changed 15 months 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 15 months ago by chriscauley

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

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

comment:4 Changed 15 months ago by bpeschier

Closed #19623 as a duplicate.

comment:5 Changed 15 months ago by bpeschier

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 15 months ago by julien

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 15 months ago by julien (next)

comment:7 Changed 14 months ago by claudep

  • Resolution set to needsinfo
  • Status changed from new to closed

comment:8 Changed 14 months ago by claudep

  • Resolution needsinfo deleted
  • Status changed from closed to new
  • Triage Stage changed from Unreviewed to Accepted

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

comment:9 Changed 14 months ago by Claude Paroz <claude@…>

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

In cb5545ea2d747e2457221a03e985ef9b4a79ee2e:

Fixed #19598 -- Fixed jQuery tagName retrieving

Thanks rj at rudiculous.net for the report.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.