javascript - How to disable all parent and childs if one parent is selected? -
here in first condition able disbale parents except current parent selected.
checkbox.js
if (geolocation.id === 5657){ var getparent = geolocation.parent(); $.each(geolocation.parent(),function(index,location) { if (location.id !== geolocation.id) { var disableitemid = 'disabled' + location.id; // **strong text**the model var model = $parse(disableitemid); // assigns value model.assign($scope, true); } } );
at point trying disbale child parents disabled in above condition. how achieve task below code appreciated.
so far tried code...
$.each(geolocation.parent().items,function(index,location) { if(location.id !== geolocation.id){ var disableitemid = 'disabled' + location.children.data; // model var model = $parse(disableitemid); // assigns value model.assign($scope, true); } }); console.log(getparent); }
if plan use angular, better express of in model structure, , use ng-click , ng-disabled achieve need.
template:
<ul> <li ng-repeat="item in checkboxes"> <input type="checkbox" ng-disabled="item.disabled" ng-click="disableothers(item)"> {{item.name}} </li> </ul>
controller:
$scope.disableothers = function (item) { // iterate on parents , childs , mark disabled true };
Comments
Post a Comment