-2

I have a onclick function attached to check Box (which selectes or Unselects all dependent checkBoxes),I am using AngularJs. So For a checkBox say X ,there are more dependant chekcboxes say A ,B ,C. So when all of the get checked X get checked automatically. And when even one of the get unchekced X get unchekced. But I need to stop "Unselecting checkBox event" from getting fired.

Is there any way possible to do that?

<span style="float: right">
    <input id="SelectAllRecords" type="checkbox" ng-model="toSelectAllEmployees"
           ng-click="selectAndAddAllEmployees($event)">{{selectAllLabel}} {{totalRecord()}}
</span>

$scope.$watch('toSelectAllEmployees',function() {
    // toSelectAllEmployees is an ng-model for select all Emp 
    if($scope.toSelectAllEmployees!=null && $scope.toSelectAllEmployees!=undefined) {   
        $scope.selectAllOrUnselectAll();
    }
});

$scope.selectAllOrUnselectAll = function() {   
    if($scope.toSelectAllEmployees!=null && $scope.toSelectAllEmployees!=undefined) {   
        if($scope.toSelectAllEmployees==true) {   
            $('.allEmployees').attr("checked", true);
        } else {
            $(".allEmployees").attr('checked',false);
            if($rootScope.fromMovingPage!=2 && $rootScope.fromMovingPage!=3) {
                // as we have now unchecked all employees hence we need to do matching and selected employee list size 0
                $scope.matchingAndSelectedEmployeesList.length = 0;
            }
        }
    }
}
edigu
  • 9,878
  • 5
  • 57
  • 80

1 Answers1

1

in the onclick event, providing you pass an event var like

function(e) {

}

you may type:

function(e) {
    e.preventDefault();
}

I believe this is what you are asking.

Limnic
  • 1,826
  • 1
  • 20
  • 45