9

I'm trying to display content on multiple lines in the tooltip of calendar entry for UI Calendar and it is not working.

Here is the code

$scope.onEventRender = function(event, element, view) {
    if(event.hover_data) {
        $timeout(function(){
            var hdata = event.hover_data.join('<br />');
            element.attr({'tooltip': hdata, 'tooltip-append-to-body': true});
            $compile(element)($scope);
        });
    }
}

Here is how it looks

enter image description here

Please let me know what I'm doing wrong.

jagmohan
  • 2,052
  • 2
  • 26
  • 41

4 Answers4

2

Stuff that worked for me. Might be useful for someone else

var tooltipText = ['Tooltip', 'text', 'to', 'be', 'split'];

$(element).tooltip({html: true, title: tooltipText.join('</br>')});
1

You doesn't able to show HTML formatted text in default plain browser tooltip. Instead of browser tooltip you should use some third party javascript libraries for showing full formatted tooltips.

Libraries such as:

Jan
  • 424
  • 5
  • 15
Mojtaba
  • 514
  • 9
  • 19
1

There is no tooltip functionality in ui-calendar. You are probably using bootstrap-ui-tooltip. Besides tooltip it also has a property tooltip-html-unsafe (since v0.3.0, released on 1 May 2013), it was renamed lately. You can read about it in some old documenatation

I made a plunker with html content tooltips

Grin
  • 6,082
  • 2
  • 22
  • 15
  • You solution 'almost' works, but the problem that it's applicable with old version of the bootstrap, I couldn't cause it work with the new version of bootstrap and `uib-tooltip-html` https://plnkr.co/edit/o5MJM4t5SM5QzFo12W0q?p=preview, Actually I have solved this problem by writing my own directive which use behind the scenes plain bootstrap jquery component, I'm not satisfied with this workaround and looking for a native angular solution if it's possible. – Anatoly Feb 20 '16 at 15:08
0

@jagmohan try this.

$( element ).tooltip({
    content: hdata
});

This works for me.

Chintan Mirani
  • 1,464
  • 9
  • 18