Bug Tracker

Opened 9 years ago

Closed 9 years ago

#14502 closed bug (notabug)

Long id Names With Periods Don't Get Selected

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:


In the following code if will have a value like "com.prodeasystems.apps.Settings". Read the code below and you will see that jquery can not select the element with that id but base javascript can.

$('#parental_apps_content').append('<div id="' + this.symbolicname + '_ON" class="parental_control_on"><img src="https://' + current_jid + '/' + this.approot + this.iconrc + '" /></div>'); $('#parental_apps_content').append('<div id="' + this.symbolicname + '_OFF" class="parental_control_off"><img src="https://' + current_jid + '/' + this.approot + this.iconrc + '" /></div>');

$('#tab_parental_apps').show(); if(this.restricted === "0") { document.getElementById(this.symbolicname + '_OFF').style.display = "block"; WORKS! $('#'+this.symbolicname + '_OFF').css("display", "block"); DOESN"T WORK, NEITHER DOES show(); document.getElementById(this.symbolicname + '_ON').style.display = "none"; $('#'+this.symbolicname + '_ON').css("display", "none"); } else { document.getElementById(this.symbolicname + '_ON').style.display = "block"; $('#'+this.symbolicname + '_ON').css("display", "block"); document.getElementById(this.symbolicname + '_OFF').style.display = "none"; $('#'+this.symbolicname + '_OFF').css("display", "none"); }

Change History (2)

comment:1 Changed 9 years ago by epascarello

So you are saying that you have an element with an id that has peroids

<div id="a.b.c.d.e">foo</div>

and you want to reference the element by its id. This is not a bug, you need to escape the periods as the docs state


If you do not escape the periods, you are looking for an element with the id of a and with classes b, c, d, and e.

comment:2 Changed 9 years ago by dmethvin

Resolution: notabug
Status: newclosed

Right. For pathological ID names, the first choice would be to use non-pathological ID names. If this sane step cannot be taken, the easiest way to select them is $(document.getElementById("I.am.a.pathological.id")).

Note: See TracTickets for help on using tickets.