0

I have a list of trs with nested tds. This is a angular based app. I am also using tooltip.js bootstrap plugin. What I'm trying to achieve is to hide a tooltip from tr when I mouseover on td. My HTML looks like this:

<tr ng-repeat="model in somelist" name="someName" tooltip="someTooltip">  

  <td tooltip="someOtherTooltip" ng-mouseover="hideTooltip()"></td>

</tr>

and .js like this:

$scope.hideTooltip = function () {
    $("[name='someName']").tooltip('hide');
};
5
  • why ng-mouseover is inside td tooltip Commented Sep 15, 2016 at 7:37
  • Ideally you would put that in a directive and not a controller Commented Sep 15, 2016 at 7:40
  • It's not. My mistake. Editing right now. Commented Sep 15, 2016 at 7:42
  • 1
    Try this $(".tooltip").hide(); Commented Sep 15, 2016 at 7:48
  • Thank you very much chiraq patel. It works. Commented Sep 15, 2016 at 7:55

3 Answers 3

1

Performing DOM manipulations from Controller is a bad practice. You have to do it from directives. In your case, as suggested above, you'd better use ngHide like so:

<tr ng-repeat="model in somelist" name="someName" tooltip="someTooltip">  
    <td tooltip="someOtherTooltip" ng-hide="tooltipIsHidden" ng-mouseover="hideTooltip()"></td>
</tr>

In your Controller:

$scope.hideTooltip = function () {
    $scope.tooltipIsHidden = true;
};

In real world, however, you'd need to pass an argument of the tooltip you want to hide, and use a property like tooltip.isHidden instead.

By the way, you might want to check out UI Bootstrap. It ccntains Bootstrap UI components wrapped in Angular directives (including tooltip) with a lot of useful options.

Sign up to request clarification or add additional context in comments.

Comments

0

you can use ngHide. I think its helpful to you cheers!!

Comments

0

My advise is to use UI Bootstrap.

Here is a link on how to use the tooltip functionality: https://angular-ui.github.io/bootstrap/#/tooltip

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.