angular-multi-select icon indicating copy to clipboard operation
angular-multi-select copied to clipboard

How to add tooltip for each dropdown element?

Open chougule-ashwini opened this issue 6 years ago • 9 comments

I want to show a tooltip for each drop-down element and that will be dynamic. Can you please help me?

chougule-ashwini avatar Apr 20 '18 08:04 chougule-ashwini

Sorry, by default the directive does not support tooltip.

isteven avatar May 07 '18 03:05 isteven

You can create a directive which name would be multiSelectItem, because isteven-multiselect directive will add multiSelectItem class on each element of dropdown. So As workaround you could create your own directive like below

Note: it should have restricted over C(class) to make it working.

    angular.module('myApp').directive('multiSelectItem', [function(){
        return {
            restrict: 'ACE',
            link: function(scope, element){
                // adding title attribute which would eventually help to show tooltip
                element.attr('title', scope.item.name);
            }
        }
    }])

pankajparkar avatar Jun 16 '18 16:06 pankajparkar

We could reuse the existing function. Just use this in the HTML. title="{{writeLabel( item, 'buttonLabel' )}}"

ArivananthamA avatar Apr 05 '19 15:04 ArivananthamA

We could reuse the existing function. Just use this in the HTML. title="{{writeLabel( item, 'buttonLabel' )}}"

@ArivananthamA could you please explain this solution? How should writeLabel() work?

here is my element

 <div id="equipment" isteven-multi-select input-model="equipment" output-model="equipmentSelection" button-label="icon name"     item-label="name" tick-property="ticked" orientation="horizontal" selection-mode="single" is-disabled="disableDir"  >
</div>

mradyuk avatar Nov 25 '19 07:11 mradyuk

Just add the attribut title="{{writeLabel( item, 'buttonLabel' )}}" in your div, will work. There is an existing function written in the library, if passing the type as buttonLabel then it will just return a label. You could see the function writeLabel in isteven-multi-select.js for better understanding.

ArivananthamA avatar Nov 25 '19 15:11 ArivananthamA

@ArivananthamA thanks, but seems it doesn't make any effect on my div <div id="equipment" isteven-multi-select input-model="equipment" output-model="equipmentSelection" button-label="icon name" item-label="name" tick-property="ticked" orientation="horizontal" selection-mode="single" is-disabled="disableDir" title="{{writeLabel( item, 'buttonLabel' )}}"> </div>

mradyuk avatar Nov 28 '19 08:11 mradyuk

You should not add there. Should be changed in the hardcoded template section at the isteven-multi-select-4.0.0.js file. '<span '+ 'ng-class="{disabled:itemIsDisabled( item )}" '+ 'title="{{writeLabel( item, 'buttonLabel' )}}" ' + 'ng-bind-html="writeLabel( item, 'itemLabel' )">'+ ''+

ArivananthamA avatar Nov 28 '19 21:11 ArivananthamA

@ArivananthamA thanks for answering, but how element itself should be configured to show my custom tooltips for each item? Seems it shows value as a tooltip

mradyuk avatar Dec 04 '19 07:12 mradyuk

In isteven-multi-select.js line 593 you can trust each item-label string as html.

e.g.:

<isteven-multi-select 
    output-model="cars"
    item-label="model" />
$scope.cars = [
   { model: `<label title="${car1.year}">${car1.model}</label>`, year: car1.year },
   { model: `<label title="${car2.year}">${car2.model}</label>`, year: car2.year }
];

blzjns avatar May 29 '20 22:05 blzjns