Excellent. Thanks for your response. The only reason mentioned that I thought 
it didn't work (the "name1 name2" thing) is because I had tried it before and 
not been successful with returning the results I needed. But... apparently I 
was wrong. I've learned a lot here.

Thanks again!
~Philip


On Jan 9, 2011, at 11:31 PM, Sean McArthur wrote:

> You can read the source of getParent from here:
> https://github.com/mootools/mootools-core/blob/1.2x/Source/Element/Element.js#L493
> 
> Essentially, if you don't provide a selector, it returns the parentNode. If 
> you provide a CSS selector, it walks up the parentNodes until it finds the 
> first match of that selector. <div class="name1 name2" /> is matched by the 
> selector ".name1" (all normal CSS applies here.)
> 
> 
> 
> On Sun, Jan 9, 2011 at 9:23 PM, Philip Thompson <[email protected]> 
> wrote:
> 1. Correct me if I'm wrong. But this scenario won't catch an element with the 
> class "name1 name2":
> 
> el.getParent('.name1')
> 
> This is looking for the exact name. So, this won't work as the method I'm 
> looking for....?
> 
> 2. For the method Sanford provided - parentWithClassById(id) - I'm concerned 
> about some potential speed issues on a page with potentially thousands of 
> elements (and potentially in a loop). Maybe some clarification with some 
> methods would help. 
> 
> $$('.theClass') ?= document.getElements('.theClass') ?= 
> document.getElements('[class=theClass]')
> 
> Aren't all of these equivalent? Is there a big difference in speed for each 
> of them? AND, the $$() method only acts on the whole document - you can't get 
> descendants from a particular element with it, correct? Also, 
> parentWithClassById() won't work if the element doesn't have an id.
> 
> Thanks for letting me pick your brains. BTW, I'm using MT 1.2.5.
> 
> ~Philip
> 
> 
> On Jan 9, 2011, at 6:04 PM, Philip Thompson wrote:
> 
>> Ok I guess I've misunderstood how el.getParent() actually works. I thought 
>> it only found the immediate parent (with optional selector). Welp thanks for 
>> clarifying. This should work as needed...
>> 
>> Happy coding. 
>> 
>> ~Philip
>> 
>> Sent from my iPhone
>> 
>> On Jan 9, 2011, at 2:10 AM, אריה גלזר <[email protected]> wrote:
>> 
>>> On Sun, Jan 9, 2011 at 8:33 AM, Philip Thompson <[email protected]> 
>>> wrote:
>>> This won't work. I'm not just looking for the immediate parent - I'm 
>>> looking for any parent/grandparent/great grandparent/etc that may have that 
>>> class. 
>>> 
>>> 1st of all, sanfords concept will work perfectly fine for this use case
>>> 2nd -why not do el.getParent('.foo')?
>>> 
>>> -- 
>>> Arieh Glazer
>>> אריה גלזר
>>> 052-5348-561
>>> http://www.arieh.co.il
>>> http://www.link-wd.co.il
>>> 
> 
> 

Reply via email to