Skip to main content

Bug Tracker

Side navigation

#11628 closed bug (invalid)

Opened April 24, 2012 04:33AM UTC

Closed April 24, 2012 08:53AM UTC

ID selector not working immediately after append

Reported by: l3akhshi@gmail.com Owned by: l3akhshi@gmail.com
Priority: low Milestone: None
Component: misc Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

I tried to fetch newly appended row to my table and change its content, it seems that the object which I have selected is somehow different from the object appended. limiting the search boundary solved the problem (the ID is guaranteed to be unique):

table is jquery object containing a table object


//below is not working

var currentRowID = "__monitoringDataRow"+(++sequenceGen);

var tr = "<tr id='"+currentRowID+"'></tr>"

if(oldRows.rows.length == 0)

table.append(tr);

var jrow = $("#"+currentRowID);

jrow.html("<td style='width:150px'>"+row.displayName+"</td><td style='width:150px'>"+row.lastDateTime+"</td><td>"+ProcessLastAction(row.lastAction, currentRowID)+"</td>");

// the content do not change although the row is appended (an empty row).


//below is working

var currentRowID = "__monitoringDataRow"+(++sequenceGen);

var tr = "<tr id='"+currentRowID+"'></tr>"

if(oldRows.rows.length == 0)

table.append(tr);

var jrow = table.find("#"+currentRowID);

jrow.html("<td style='width:150px'>"+row.displayName+"</td><td style='width:150px'>"+row.lastDateTime+"</td><td>"+ProcessLastAction(row.lastAction, currentRowID)+"</td>");

// the content do not change although the row is appended (an empty row)

Attachments (0)
Change History (4)

Changed April 24, 2012 04:35AM UTC by l3akhshi@gmail.com comment:1

the last line of my bug report is pasted incorrectly. it should be :

it works fine!

sorry for the copy-paste mistake

Changed April 24, 2012 07:56AM UTC by sindresorhus comment:2

owner: → l3akhshi@gmail.com
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

Changed April 24, 2012 08:51AM UTC by l3akhshi@gmail.com comment:3

status: pendingnew

sorry for submitting this ticket!

It seems that it was my own mistake. to tell more about the condition were this was happening here is the scenario:

1-I had a table where in 2sec intervals, some rows where removed and where replaced by new ones.

2-later I added a feature by which some of these rows could contain a sub-table

3-this was the root of the problem! my new row was added to main table and all sub-tables! and when I tried selecting the row using rowID it jQuery was returning the row which was located in sub-tables.

Due to strict timing and the idea of "''selecting by rowID will give me what I want''" I was not able to find my mistake ;)

thank you again

Changed April 24, 2012 08:53AM UTC by sindresorhus comment:4

component: unfiledmisc
resolution: → invalid
status: newclosed