2

요소가 비활성화되었을 때 트위터 부트 스트랩 툴팁이 표시되지 않도록하려고합니다. 다음 코드로 그렇게 할 수 있습니다 :요소가 비활성화되었을 때 툴팁을 동적으로 비활성화하십시오.

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}); 
       } 
      } 
    }; 

}); 

그러나 페이지가로드되고 요소가 이미 비활성화 된 경우에만 작동합니다. 툴팁을 동적으로 비활성화하는 방법이 필요합니다. 예를 들어 스코프 변수 (editing_bln)의 값을 변경하는 버튼 (edit)을 클릭하면 ngDisabled와 scope_preting_bln을 통해 두 번째 버튼 버튼 (save)이 비활성화됩니다. 이제 툴팁이 비활성화되기를 원합니다. 그러나 link_function에서 attrs. $ observe를 사용하여 시도했는데, 페이지가로드 될 때 호출되고 변수 editing_bln이 변경 될 때 호출되지 않습니다. 버튼 코드는 다음과 같습니다.

<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 to 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 to group." class="icon-plus"></i></button> 

링크 기능에서 마크가 누락되었다고 생각합니다. 모든 답장을 보내 주셔서 감사합니다. 본질적으로 전혀 유발하지 않도록 툴팁을 일으키는 인식 트리거에 툴팁 트리거를 설정 당신이 할 시도 할 수

답변

1

:

<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 to group." 
     tooltip-trigger={{ editing_bln ? 'none' : 'mouseenter'}}" 
     class="icon-plus"></i> 
</button> 
관련 문제