#895 closed bug (fixed)
js error when selecting a non unexisting id (description below)
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | critical | Milestone: | 1.1.3 |
Component: | core | Version: | 1.1.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
I'm using jQuery-1.1.1.js.
I have the following js code:
$("#componentId #menuId").bind("click", function(e) { //do something useful. });
and this markup:
<div id="componentId"> <div id="menuId">Text</div> </div>
This works ok... but, suppose that the generated markup will not contain a div with "componentId" ID, as below:
<div id="anotherComponentId"> <div id="menuId">Text</div> </div>
... then the script will throw an error at the line 954 :
if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
I know that this issue can be avoided by changing my query code to:
$("#componentId").find("#menuId").bind("click", function(e) { //do something useful. });
instead of
$("#componentId #menuId").bind("click", function(e) { //do something useful. });
... still I think this is a bug which could be fixed. What do you think?
Thank you! Regards, Alex.
PS: I enjoy jQuery very much, it is a wonderful library. Keep doing a great job!
Change History (5)
comment:1 Changed 16 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 16 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:3 Changed 16 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
This is still not working in 1.1.2. Please fix.
comment:4 Changed 16 years ago by
(Since your bug tracker doesn't seem to show duplicate bugs, also see http://dev.jquery.com/ticket/881)
comment:5 Changed 16 years ago by
Milestone: | → 1.1.3 |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
Version: | → 1.1.1 |
Fixed in SVN rev [1573].
According to tests this works in the latest revision of jQuery.