[jQuery] Re: Bug? $('#foo #bar')

2007-06-06 Thread Klaus Hartl


Karl Swedberg wrote:


On Jun 4, 2007, at 5:38 PM, Klaus Hartl wrote:

Makes perfect sense. 



phew! I was hoping you would say that. :-)


No need for fear Karl! You know we share the same mindset!


--Klaus


[jQuery] Re: Bug? $('#foo #bar')

2007-06-05 Thread Matt Kruse

On Jun 5, 11:54 am, "Sean Catchpole" <[EMAIL PROTECTED]> wrote:
> My point is that, id's and classes are the same except for the fact
> that you can only have one id per element, and only one of each id per
> page. If you remove that uniqueness of id's then it strips much of
> it's purpose.

CSS Specificity is a big reason to use id's. You can make a rule using

#id { ... }

and know that it will take precedence over all your tag/class-based
rules.

Matt Kruse




[jQuery] Re: Bug? $('#foo #bar')

2007-06-05 Thread R. Rajesh Jeba Anbiah

On Jun 5, 9:54 pm, "Sean Catchpole" <[EMAIL PROTECTED]> wrote:
> I suppose I can see a few applications of using multiple id's, but I'm
> still curious why using classes instead is not a better option.
  

1. CSS designers don't have to scratch their heads forming the
selectors.
   It's simple, login.php will have login as id, signup.php will have
signup as id. So, bending the design is quite easy--when you already
have formed the global selectors

2. See my point #2 above in other thread.

--
  
Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/



[jQuery] Re: Bug? $('#foo #bar')

2007-06-05 Thread Sean Catchpole


I suppose I can see a few applications of using multiple id's, but I'm
still curious why using classes instead is not a better option.

On 6/5/07, patcoll <[EMAIL PROTECTED]> wrote:

#home #logo
#interior #logo


You could for example have 


My point is that, id's and classes are the same except for the fact
that you can only have one id per element, and only one of each id per
page. If you remove that uniqueness of id's then it strips much of
it's purpose.

I do however see that when including various pages (say via ajax)
there can be multiple copies of an id.

~Sean


[jQuery] Re: Bug? $('#foo #bar')

2007-06-05 Thread patcoll

I second this notion. A perfect example from a current project:

I have two page templates: home and interior. On each I have the
client's logo, but they are different sizes. I use an id of "logo" on
both because something bothered me about using "#home-logo" and
"#interior-logo". If I put an id of "home" or "interior" on the
outermost div, I can style the div with an id of "logo" differently on
both pages in my CSS:

#home #logo
#interior #logo

This works perfectly for my needs and keeps my code clean. Makes me
happy.

Pat

On Jun 5, 1:38 am, "R. Rajesh Jeba Anbiah"
<[EMAIL PROTECTED]> wrote:
> On Jun 4, 10:28 pm, "Sean Catchpole" <[EMAIL PROTECTED]> wrote:
>
> > More importantly, why are you using two ID's?
> > Remember, ID's are supposed to be unique, so just $('#bar') should work.
> > If your ID's aren't unique, I highly suggest you change them to classes.
>
>I have a setup where every page will have it's unique id (wrapped
> around all other elements next to body, say )
>
> Benefits:
> 1. CSS designer can bend the design specific to a particular page.
> Say, for example, all the pages have some statement blah
> blah, but the client wants that statement to be highlighted only
> on a login page. So,
> #login #bar{
>background-color: yellow;
>
> }
>
> 2. Can easily apply CSS techniques such as   print/css-anthology-tips-tricks-4> (Figure 4.20)
>
>Similarly I want to apply the selector in jQuery too, so that the
> rules wouldn't be global for every page; but specific to a single
> page.
>
> --
>   
> Email: rrjanbiah-at-Y!comBlog:http://rajeshanbiah.blogspot.com/



[jQuery] Re: Bug? $('#foo #bar')

2007-06-04 Thread R. Rajesh Jeba Anbiah

On Jun 4, 10:28 pm, "Sean Catchpole" <[EMAIL PROTECTED]> wrote:
> More importantly, why are you using two ID's?
> Remember, ID's are supposed to be unique, so just $('#bar') should work.
> If your ID's aren't unique, I highly suggest you change them to classes.

   I have a setup where every page will have it's unique id (wrapped
around all other elements next to body, say )

Benefits:
1. CSS designer can bend the design specific to a particular page.
Say, for example, all the pages have some statement blah
blah, but the client wants that statement to be highlighted only
on a login page. So,
#login #bar{
   background-color: yellow;
}

2. Can easily apply CSS techniques such as   (Figure 4.20)

   Similarly I want to apply the selector in jQuery too, so that the
rules wouldn't be global for every page; but specific to a single
page.

--
  
Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/



[jQuery] Re: Bug? $('#foo #bar')

2007-06-04 Thread Karl Swedberg


On Jun 4, 2007, at 5:38 PM, Klaus Hartl wrote:


Makes perfect sense.


phew! I was hoping you would say that. :-)

--Karl
_
Karl Swedberg
www.englishrules.com
www.learningjquery.com



[jQuery] Re: Bug? $('#foo #bar')

2007-06-04 Thread Klaus Hartl


Karl Swedberg wrote:

here we go again... :-)

I replied to a similar question regarding specifying an ID inside of a 
class a few days ago.


same thing applies to ID inside an ID...

This paragraph from the reference section of the upcoming Learning 
jQuery book might help explain why someone would want or need to 
preselect a class first. It discusses specifying a tag name rather 
than a class, but the same principle applies:


It might not be immediately clear why someone might want to specify a 
tag name associated with a particular id, since that id needs to be 
unique anyway. However, some situations in which parts of the DOM are 
user-generated may require a more specific expression to avoid false 
positives. Furthermore, when the same script is run on more than one 
page, it might be necessary to identify the id's element, since the 
pages could be associating the same id with different elements. For 
example, Page A might have  while Page B has id='title'>. 


Hope that makes sense.


Makes perfect sense. Another example to illustrate this is a result from 
a search.


If there's nothing found from the search you maybe render a paragraph 
like this:



No items found. Please try another search.


Whereas for a result with found items you would use a list:


...


Presentation and maybe behavioral enhancement maybe based off the type:

p#search-result {
/* some styles */
}

ul#search-result {
/* some other styles */
}


Which is nothing else than relying on an element with a certain id 
nested in another one in one situation opposed to some other structure 
in a slightly different case.



--Klaus





[jQuery] Re: Bug? $('#foo #bar')

2007-06-04 Thread Karl Swedberg

here we go again... :-)

I replied to a similar question regarding specifying an ID inside of  
a class a few days ago.


same thing applies to ID inside an ID...

This paragraph from the reference section of the upcoming Learning  
jQuery book might help explain why someone would want or need to  
preselect a class first. It discusses specifying a tag name rather  
than a class, but the same principle applies:


It might not be immediately clear why someone might want to  
specify a tag name associated with a particular id, since that id  
needs to be unique anyway. However, some situations in which parts  
of the DOM are user-generated may require a more specific  
expression to avoid false positives. Furthermore, when the same  
script is run on more than one page, it might be necessary to  
identify the id's element, since the pages could be associating  
the same id with different elements. For example, Page A might  
have  while Page B has .


Hope that makes sense.

--Karl
_
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Jun 4, 2007, at 1:28 PM, Sean Catchpole wrote:



More importantly, why are you using two ID's?
Remember, ID's are supposed to be unique, so just $('#bar') should  
work.
If your ID's aren't unique, I highly suggest you change them to  
classes.


~Sean




[jQuery] Re: Bug? $('#foo #bar')

2007-06-04 Thread Sean Catchpole


More importantly, why are you using two ID's?
Remember, ID's are supposed to be unique, so just $('#bar') should work.
If your ID's aren't unique, I highly suggest you change them to classes.

~Sean


[jQuery] Re: Bug? $('#foo #bar')

2007-06-04 Thread R. Rajesh Jeba Anbiah

On Jun 4, 4:52 pm, SeViR <[EMAIL PROTECTED]> wrote:
> The bug is repaired in 1.1.3a
   

   Oh, cool. Thanks

--
  
Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/



[jQuery] Re: Bug? $('#foo #bar')

2007-06-04 Thread SeViR


The bug is repaired in 1.1.3a

- Original Message -
Subject: [jQuery] Bug? $('#foo #bar')
Date: Mon, 04 Jun 2007 04:42:48 -0700
From: "R. Rajesh Jeba Anbiah"


jQuery 1.1.2

Selectors such as this $('#foo #bar') throwing error when it can't
find any matches. Is it a known bug? TIA

--

Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/


--
Best Regards,
José Francisco Rives Lirola 

SeViR CW · Computer Design
http://www.sevir.org
 
Murcia - Spain