If you can do it in the server, do it there :) If not (maybe the data
is created in js and it's still not available in the server, for
example), a possibility is to use Enumerable#partition:

$$(".new, .read").partition(function(d) { return
d.className.match(/new/) }).flatten();

http://prototypejs.org/api/enumerable/partition

Best,
-Nicolas

(ps: wow, first time I find an actual use for Enumerable#partition)

On Feb 1, 2008 12:04 PM, Wizz <[EMAIL PROTECTED]> wrote:
>
> On 31 jan, 21:47, polomasta <[EMAIL PROTECTED]> wrote:
> > I guess they can the first time. However, a button in the div can be
> > clicked to change its status (class) from "new" to "read" or vice
> > versa... when this happens I want to resort the divs without having to
> > reload everything from the server again.
> >
> > Does that make sense?
> >
> > On Jan 24, 7:07 pm, "Justin Perkins" <[EMAIL PROTECTED]> wrote:
> >
> > > On Jan 24, 2008 4:10 PM, polomasta <[EMAIL PROTECTED]> wrote:
> >
> > > > I have a script that pulls in a bunch of data to my page and parses it
> >
> > > Is this data being pulled in through an Ajax request? Why can't the
> > > data be sorted on the server?
> >
> > > -justin
> I would suggest making 2 arrays with the 'new' divs and the 'read'
> divs and merging the afterwards.
>
> sortMessages($('container'));
>
> function sortMessages(container) {
>   var read = container.select('div.read');
>   var new = container.select('div.new');
>   var result = $A([]);
>   return result.concat(new, read);
> }
>
> Haven't tested it though... but this is the general idea
>
> Greetz,
>
> Wizz
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to