On 1.11.2008, at 17.57, Matt wrote:

> On Oct 31, 8:20 pm, Jarkko Laine <[EMAIL PROTECTED]> wrote:
>> Matt, could you elaborate a bit more?
>>> $$('#container_'+boxID+' span');
>> actually looks to be fine. What are you getting with it and what are
>> you expecting?
>> //jarkko
> I'm getting the literal string, $$('#container_'+boxID+' span'), with
> the plus symbols and everything. I'm expecting something like so:
> function foo(boxID)
> {
> var bar =  $$('#container_'+boxID+' span');
> alert("bar");
> }

1) your alerting with a string "bar" there.
2) $$ returns an array of elements. If you want a single item, why not  
give the span a unique id and call it with $? If you need to use the  
double-dollar selector, you need to get the first element of the array  
to get the actual element: $$('#container_'+boxID+' span')[0]; One  
option that gives you the span element (with the html syntax you  
posted before) is this: $('container_' + boxID).down('span').

> <a href="#" onclick="foo("24");">click here</a>
> // returns "$$('#container_24 span')";

You mean the function above alerts that string? Frankly, I don't  
believe you :-)

The parameter that $ and $$ take is just a normal string. There's  
nothing magical about it. So if you can do "string" + someVar, and the  
result is a string, you can give it as a parameter to those functions.


Jarkko Laine

Check out my latest book, Unobtrusive Prototype, fresh off the  
Peepcode oven:

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to