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
>> 

"innerHTML is a string. The DOM is not a string, it's a hierarchal object 
structure. Shoving a string into an object is impure and similar to wrapping a 
spaghetti noodle around an orange and calling it lunch."

Reply via email to