Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I implement a gmail-style label chooser?

What's the easiest way to implement (something like) Gmail's interface for labeling messages? Does any javascript library have a widget like this?

http://img294.imageshack.us/img294/7097/36698396.png

Behavior:

  1. Click a label in the dropdown to immediately label the message.
  2. Check multiple labels and then "Apply" to add multiple labels (not sure I like the "Apply" requirement...)
  3. Type in the box to narrow down your list of labels. If you narrow it down to 1, pressing enter applies that label.
  4. Trigger the widget with the shortcut key "L".
like image 284
Tom Lehman Avatar asked Dec 05 '25 06:12

Tom Lehman


2 Answers

Horace - you want something really complicated, and you should take into account that even with a lot of pre-made component, it will take some time to get something like this working (not to mention - being pretty :-) ).

Anyway, pre-made components are nice but I often like to hack it myself, free-style like. So here is something I cooked up to get you going: My simple label demo (warning - I only tested this on Firefox 3 and I'm pretty sure that it won't work in anything else).

It is far from being pretty, but the code is pretty straight forward and should be easy to understand.

like image 100
Guss Avatar answered Dec 07 '25 20:12

Guss


I was looking for a similar label implementation, and stumbled on this thread.

I can't add to the JS part of the question, but in terms of the "prettiness" of the labels, you might find the following article/code useful:

CSS Gmail-Like Labels

All the best!


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!