Bug Tracker

Ticket #11628 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

ID selector not working immediately after append

Reported by: l3akhshi@… Owned by: l3akhshi@…
Priority: low Milestone: None
Component: misc Version: 1.4.2
Keywords: Cc:
Blocking: Blocked by:

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)

Change History

comment:1 Changed 2 years ago by l3akhshi@…

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

it works fine!

sorry for the copy-paste mistake

comment:2 Changed 2 years ago by sindresorhus

  • Owner set to l3akhshi@…
  • Priority changed from undecided to low
  • Status changed from new to pending

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.

comment:3 Changed 2 years ago by l3akhshi@…

  • Status changed from pending to new

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

comment:4 Changed 2 years ago by sindresorhus

  • Status changed from new to closed
  • Resolution set to invalid
  • Component changed from unfiled to misc
Note: See TracTickets for help on using tickets.