tag-it icon indicating copy to clipboard operation
tag-it copied to clipboard

Added Ability to display label instead of value

Open tareko opened this issue 12 years ago • 13 comments

Not all use cases involve the Value and Label being the same. This functionality makes it so that 'label' will be displayed, while 'value' will be submitted to the form.

Some if/then statements mean that if no Label is found, the Value is used - as before.

tareko avatar May 14 '12 00:05 tareko

A bug that I discovered is that the ID and not the label will be displayed if a person keys over to the appropriate entry.

tareko avatar May 17 '12 03:05 tareko

Excellent feature !!

aklein-dex avatar Jul 13 '12 02:07 aklein-dex

Doesn't appear to work when using the down key to select an autocomplete option. that.createTag(that._cleanedInput()); is called without the jquery ui item.

jjlharrison avatar Sep 13 '12 12:09 jjlharrison

It's ok when I use mouse to select the autocomplete option. But if I use the down key it will display ID instead of label. How to solve this issue??

n3ISe avatar Sep 20 '12 10:09 n3ISe

@n3ISe I've fixed that issue in my fork: https://github.com/jjlharrison/tag-it

jjlharrison avatar Sep 20 '12 10:09 jjlharrison

Thanks @jjlharrison

n3ISe avatar Sep 20 '12 10:09 n3ISe

+1

You could create a branch with this and refactor later.

jlebrech avatar Jan 23 '13 09:01 jlebrech

@n3ISe To fix the issue with key down you have to implement a function for autocomplete 'focus' property,like this:

$("#myInput").tagit({
autocomplete: {
focus: function (event, ui) {
                        $(this).val(ui.item.label);
                        return false;
                    }
    }
});

Also,When tareko's changes are going to be merged into the master repository ?

alaa9jo avatar May 07 '13 15:05 alaa9jo

+1. Would be really nice to add this feature.

If not ready for merge, what is missing? We may perhaps help? :)

jpetitcolas avatar Sep 13 '13 13:09 jpetitcolas

Any update on this?

KerryJones avatar Jun 06 '14 18:06 KerryJones

I was able to fix this issue by editing my jquery-ui.js file.

I am using jQuery UI version 1.10.4, it was on line 2267. I needed to change:

if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {      this._value( item.value ); }

to

if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {      this._value( item.label ); }

fadedthrough avatar Jun 10 '14 17:06 fadedthrough

+1, started integrating this plugin but realized I can't use it in its current state.

mhuggins avatar Jan 25 '15 15:01 mhuggins

+1

mubashirkamran avatar Oct 10 '16 09:10 mubashirkamran