angularjs - Dynamically disable tooltip when element becomes disabled -
i trying prevent twitter bootstrap tooltip showing when element disabled. able following code:
app.directive("tooltip",function(){ return { restrict:"a", require: 'tooltipdirection', link:function(scope,element,attrs,directioncontroller){ attrs.$observe('ngdisabled',function(){ console.log("ngdisabled has changed: " + attrs.ngdisabled); }); if(scope.$eval(attrs.ngdisabled)!=true){ $(element).attr('title',attrs.tooltip).tooltip({placement:directioncontroller.direction}); } } }; });
however, works when page loads , element disabled. need way of dynamically disabling tooltip. example, if click on button (edit) changes value of scope variable(editing_bln), 2nd button button (save) becomes disabled via ngdisabled , scope variable, editing_bln. want tooltip disabled - not. tried using attrs.$observe in link function, however, getting called when page loads , not when variable, editing_bln, changes. here button code:
<button type="button" ng-class="{'btn-danger':editing_bln}" class="btn btn-mini" style="margin-top:10px;margin-left:20px;" ng-click="editing_bln = !editing_bln"><i tooltip-direction="top" tooltip="click edit content" ng-class="{'icon-white':editing_bln}" class="icon-pencil"></i></button> <button ng-disabled="editing_bln" type="button" class="btn btn-mini" style="margin-top:10px;" ng-click="responseadd()"><i tooltip-direction="top" tooltip="add response group." class="icon-plus"></i></button>
i guessing missing mark in linking function. , replies.
what can try set tooltip-trigger unrecognized trigger, causes tooltip not trigger @ all:
<button ng-disabled="editing_bln" type="button" class="btn btn-mini" style="margin-top:10px;" ng-click="responseadd()"> <i tooltip-direction="top" tooltip="add response group." tooltip-trigger={{ editing_bln ? 'none' : 'mouseenter'}}" class="icon-plus"></i> </button>
Comments
Post a Comment