Hi
On 6/9/06, Jorge Godoy <[EMAIL PROTECTED]> wrote:
> Is there something that I can use to sort the options inside a select
> accordingly to what is shown to the user? I'm getting a Python dict
> (unordered) in JSON format and I'd like to sort this to make options easier
> to find when browsing the list...
I'm not sure if you mean sorting the <option> elements after inserting
them into the DOM or before. I would do something like this:
map(function (key) {
$('yourselect').appendChild(OPTION({'value': key}, yourjsonobject[key]));
}, keys(yourjsonobject).sort());
Perhaps there's a better way?
Arnar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" 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/mochikit
-~----------~----~----~----~------~----~------~--~---