[jQuery] Re: Something changed from 1.2.2 to 1.3.2 with hashes

2009-05-20 Thread John Resig
Well, in 1.3.2 it now throws an exception, since the CSS selector # is
invalid. If you wish to use that precise technique I'd wrap a try/catch
around the jQuery statement to catch the error.

--John


On Wed, May 20, 2009 at 8:22 AM, madmax019 maxi.karr...@googlemail.comwrote:


 Hi everyone,

 I have the following problem with the latest jQuery version. Thanks
 already to anyone wanting to help me.

 With jQuery 1.2.2 I could get a targets hash like this:

var $target = $(this.hash);

 Sometimes, people use just href=# to get to the top of page and not
 href=#header (or similar). Hence, if it was just a #, I considered
 it to have an undefined target. Now to check whether the hash is
 undefined or not, I used the following:

var $defined = $target.length;

 Now if the hash was undefined, I would get a zero. If it was defined,
 I would get a 1. Then with a simple if statement I was able to sort
 through the stuff...

 Apparently with jQuery 1.3.2 this is no longer possible? Anyone know
 why and possibly know a fix to this?

 Thanks

 Max



[jQuery] Re: Something changed from 1.2.2 to 1.3.2 with hashes

2009-05-20 Thread Max

Thanks - that worked perfectly.

Max

On May 20, 3:39 pm, John Resig jere...@gmail.com wrote:
 Well, in 1.3.2 it now throws an exception, since the CSS selector # is
 invalid. If you wish to use that precise technique I'd wrap a try/catch
 around the jQuery statement to catch the error.

 --John

 On Wed, May 20, 2009 at 8:22 AM, madmax019 maxi.karr...@googlemail.comwrote:





  Hi everyone,

  I have the following problem with the latest jQuery version. Thanks
  already to anyone wanting to help me.

  With jQuery 1.2.2 I could get a targets hash like this:

             var $target = $(this.hash);

  Sometimes, people use just href=# to get to the top of page and not
  href=#header (or similar). Hence, if it was just a #, I considered
  it to have an undefined target. Now to check whether the hash is
  undefined or not, I used the following:

             var $defined = $target.length;

  Now if the hash was undefined, I would get a zero. If it was defined,
  I would get a 1. Then with a simple if statement I was able to sort
  through the stuff...

  Apparently with jQuery 1.3.2 this is no longer possible? Anyone know
  why and possibly know a fix to this?

  Thanks

  Max