thats what im looking for!  thanks

On Oct 24, 10:44 am, Aaron Newton <[email protected]> wrote:
> I knew that was in there somewhere.
>
> On Sat, Oct 24, 2009 at 12:33 AM, Jan Kassens <[email protected]> wrote:
> > or use Element.appendText (
> >http://mootools.net/docs/core/Element/Element#Element:appendText) which
> > keeps the references.
>
> > // target = where to insert
> > // links = array of <a> Elements.
> > links.each(function(link, i){
> > target.grab(link);
> > if (i < links.length - 1){
> >  target.appendText(', ');
> > }
> > });
>
> > // untested code.
>
> > On 23.10.2009, at 20:20, Aaron Newton wrote:
>
> > var links = [];
> > var link = new Element('a', {'href':...})
> > links.push(link);
> > ...
> > links.each(function(link){
> >  div.adopt(link);
> >  div.innerHTML += ', ';
> > });
>
> > The problem here is if you want to retain any references to those links
> > (let's say you've attached events to them) you can't use their string (html)
> > values to concatenate a string with commas. If you don't want to inject a
> > dom element between them (like a span), you can't use "new Element". If you
> > use set('html') you'll blow away the references, too. So you must append to
> > innerHTML.
>
> > On Fri, Oct 23, 2009 at 10:48 AM, TheIvIaxx <[email protected]> wrote:
>
> >> so i start with a JSON string of information, from this JSON object i
> >> construct links by:
>
> >> var links = [];
> >> var link = new Element('a', {'href':...})
> >> links.push(link);
>
> >> lets says i have 3 links in the links array.  Now i need to join these
> >> links with a comma and put them into a DIV that results in the
> >> following html:
>
> >> <div>
> >>    <a href="...">...</a>,
> >>    <a href="...">...</a>,
> >>    <a href="...">...</a>
> >> </div>
>
> >> i could just loop through these and kind of reconstruct the html from
> >> the elements, but i was wondering if there was a fancy way to do it.
>
> >> sorry for the use of "link" above, hope its not confusing.
>
> >> On Oct 22, 11:22 pm, csuwldcat <[email protected]> wrote:
> >> > here it is in MooShell:http://mooshell.net/MkrV7/
>
> >> > On Oct 22, 11:17 pm, csuwldcat <[email protected]> wrote:
>
> >> > > If you just want the hrefs in an array do what Aaron said, if you want
> >> > > some span on a page for instance to be populated with links having
> >> > > commas between them then do something like i suggested, again i havent
> >> > > tested that...
>
> >> > > On Oct 22, 11:13 pm, csuwldcat <[email protected]> wrote:
>
> >> > > > $$('a').each(function(e, i, a){ yourElement.grab(e).appendText((i <
> >> > > > a.length -1) ? ',' : ''); });
>
> >> > > > I didnt test that yet, but try it out.
>
> >> > > > On Oct 22, 10:24 pm, "Steve Onnis" <[email protected]> wrote:
>
> >> > > > > getElements("a").toString()
>
> >> > > > > All yo uwill get though is "object,object,object"
>
> >> > > > > What are you trying to do with them?
>
> >> > > > > -----Original Message-----
> >> > > > > From: TheIvIaxx [mailto:[email protected]]
> >> > > > > Sent: Friday, 23 October 2009 4:07 PM
> >> > > > > To: MooTools Users
> >> > > > > Subject: [Moo] join a list of elements
>
> >> > > > > If i have an array of 'a' Elements and i would like to join them
> >> with
> >> > > > > a ',' resulting in a list of comma separated links on a page.  Is
> >> > > > > there a quick way to do this in mootools?
>
> >> > > > > Thanks

Reply via email to