javascript - AngularJS ng-click element within directive often unclickable, or clickable outside of element -
i have simple angularjs directive contracts title if title exceeds length. when contracted, there small chevron icon clickable show full title. when full title displayed, chevron shown contract it. first chevron clickable 10 pixels above icon itself, , 'contract' icon unclickable, though displayed.
directive:
(function(){ 'use strict'; angular .module('main') .directive('headertitle', headertitle); function headertitle() { return { restrict: 'e', scope: { brand: '=', generic: '=', suffix: '=' }, template: '{{ brand }} <span id="title-suffix" ng-class="{abbreviated:abbreviate}">{{ generic }} {{ suffix }}</span>' + '<span ng-click="showfulltitle()" ng-show="abbreviate" class="expand-title"><i class="fa fa-chevron-right"></i></span>' + '<span ng-click="contracttitle()" ng-show="contract" class="contract"><i class="fa fa-chevron-left"></i></span>', link: function(scope, elem, attrs, fn) { scope.generic = (scope.generic) ? '(' + scope.generic + ')' : ''; scope.suffix = (scope.suffix) ? scope.suffix : ''; scope.abbreviate = ((scope.brand.length + scope.generic.length + scope.suffix.length) > 35) ? true : false; scope.showfulltitle = function() { scope.abbreviate = !scope.abbreviate; scope.contract = true; } scope.contracttitle = function() { scope.abbreviate = !scope.abbreviate; scope.contract = false; } } }; } })();
html partial:
<div id="drugs-drugdetail" class="container"> <div id="fullscreenonly" fullscreen="isfullscreen"> <div class="panel panel-default"> <div class="panel-heading report"> <div class="h3 report-header"> <div id="drugdetail-report-header" class="title pull-left"> <header-title brand="drug.aedrug_name" generic="drug.aedrug_generic" suffix="titlesuffix"></header-title> <div class='drug-report-header-container'> <div class='drug-report-data'> <div class='primary-suspect-cases'> <span class="header-label h4" id="drugdetail-cases-label">primary suspect cases:</span> <span class="h4" id="drugdetail-cases-value">{{ metrics.counts.primary | number }}</span> </div> <div class='data-complete-through'> <div class='drug-report-data'> <span class="header-label h4" id="drugdetail-date-label">data complete through: <span class="h4" id="drugdetail-date-value"> {{ data_updated }}</span></span> </div> </div> </div> <div class="drug-header-buttons"> <div class="header-button-padding"> <button ng-click="gofullscreenviawatcher()" class="btn btn-primary"><i class="fa aexicon-desktop"></i></button> <button ng-click="localstorageclearall()" class="btn btn-primary reset-grid-button">reset grids</button> <span class="dropdown"> <compare-menu categories="overviewdata"></compare-menu> </span> //redacted code readability...
i discovered of legacy code had modified line-heights overlapping chevron, making visible unclickable. rewrote html , css header, , works fine.
Comments
Post a Comment