Skip to main content

Bug Tracker

Side navigation

#895 closed bug (fixed)

Opened January 30, 2007 11:27AM UTC

Closed March 24, 2007 03:01AM UTC

Last modified June 21, 2007 04:16AM UTC

js error when selecting a non unexisting id (description below)

Reported by: alexandru.objelean@i Owned by:
Priority: critical Milestone: 1.1.3
Component: core Version: 1.1.1
Keywords: Cc:
Blocked by: Blocking:
Description

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!

Attachments (0)
Change History (5)

Changed January 31, 2007 09:12PM UTC by joern comment:1

description: 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!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!

Changed January 31, 2007 09:20PM UTC by joern comment:2

resolution: → worksforme
status: newclosed

According to tests this works in the latest revision of jQuery.

Changed February 28, 2007 10:03PM UTC by jgrucza comment:3

resolution: worksforme
status: closedreopened

This is still not working in 1.1.2. Please fix.

Changed February 28, 2007 10:06PM UTC by jgrucza comment:4

(Since your bug tracker doesn't seem to show duplicate bugs, also see http://dev.jquery.com/ticket/881)

Changed March 24, 2007 03:01AM UTC by john comment:5

milestone: → 1.1.3
resolution: → fixed
status: reopenedclosed
version: → 1.1.1

Fixed in SVN rev [1573].