4

In my case, tooltip is coming when user place mouse on input control but I want to trigger tooltip. Means when validation will fail, then tooltip will be display below input control.

this is the code i am using to show tooltip. just tell me what to edit in this code.

var options = { html: true, placement: 'bottom', title: '<div class="tooltip-alert alert-danger" data-placement="bottom">' + message + '</div>' };
        $(inputElement).addClass('validation-error');
        inputElement.tooltip("destroy")
            .addClass("error")
            .tooltip(options);

thanks

Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Thomas
  • 33,544
  • 126
  • 357
  • 626

2 Answers2

3

Use this way:

$(element).tooltip("show");

So, when the validation error occurs, you need to use:

inputElement.tooltip("show");
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
3

After going through the comments, I feel you need a static tooltip to be displayed when there is an error.

Bootstrap tooltip trigger=manual is what you require.

Here is the fiddle for you : Fiddle

Edit Added Hide button to hide tooltip.

Fiddle# 2

Hope this helps.

-Help :)

Help
  • 1,156
  • 7
  • 11
  • in your fiddle there should be another button which would close tooltips when clicked. in my case tooltips is generated dynamically in each table cell. – Thomas Jan 18 '16 at 12:12
  • thanks for your code. when so many tooltips is opened then how could i close all. suppose tooltip related html is there in my each td and now i want to iterate table and extract one by one tooltip and hide it......how it will be possible? – Thomas Jan 18 '16 at 12:20
  • just have a look at this post http://stackoverflow.com/questions/34854273/jquery-how-hide-or-close-all-open-bootstarp-tooltip – Thomas Jan 18 '16 at 12:20