My table looks like this, with more than one tbody:
<tbody>
<tr class='group-header' ng-click="collapseDetail($event)"> ... </tr>
<tr class='detail' ng-hide="groupIsCollapsed()">...</tr>
<tr class='group-footer'> ... </tr>
</tbody>
<tbody>
<tr class='group-header' ng-click="collapseDetail($event)"> ... </tr>
<tr class='detail' ng-hide="groupIsCollapsed($event)">...</tr>
<tr class='group-footer'> ... </tr>
</tbody>
In my collapseDetail()
function I toggle a class collapsed
on the tbody
.
And so I would like to have the detail row hidden only if the parent tbody hasClass('collapsed`).
Is that legal? What I have isn't working:
$scope.collapseDetail = function (e) {
var targ = angular.element( e.currentTarget );
$scope.$apply( function(targ){
targ.parent().toggleClass('collapsed');
});
}
$scope.groupIsCollapsed = function (e) {
if (e == undefined) return false;
var targ = angular.element( e.currentTarget );
return targ.parent().hasClass('collapsed');
}