简体   繁体   English

当子容器div处于活动状态时,如何禁用父背景div?

[英]How can I disable parent background div when a child container div is active?

I want to disable a parent background div which contains grid with data . 我想禁用包含数据网格父背景div On the grid there are options like sorting and exporting the data into csv/pdf . 在网格上,有诸如将数据排序和导出到csv/pdf Also, on this grid there is a filter button, on click of which(via ng-click= xyz(); ) a filter overlay comes. 另外,在此网格上还有一个过滤器按钮,单击该按钮(通过ng-click= xyz(); )会出现一个过滤器叠加层。 This is a child container div inside the parent div . 这是一个子容器div父里面div I want to disable the parent grid div when this filter overlay div opens ie, disable the sorting and export and any other functionalities on the parent div . 我想在此过滤器覆盖div打开时禁用父网格div,即禁用父div上的排序和导出以及任何其他功能。

Any help form anyone? 任何人都有帮助吗? My entire project is in angular js . 我的整个项目都在angular js An example with a demo will be great! 一个带有演示的示例会很棒!

In agg.service.js 在agg.service.js中

angular.module('ccar14a.common').factory('ccar14a.common.AggService', [
'ccar14a.common.Config',
'StatusService',
'ccar14a.common.TcnService',
'ccar14a.common.PivotService',
'ccar14a.common.GridConfigService',
'$timeout',
function(Config, StatusService, TcnService, PivotService, GridConfigService, $timeout) {

    var service = { 
            openFilterOverlay: function() {
            console.log("Toggle Filter overlay00");

           var filteroverlay = angular.element(".filter-overlay");

           if(filteroverlay.hasClass('open')) {

               filteroverlay.removeClass('open');
           } else {
               filteroverlay.addClass('open');
           }
            angular.element('.tooltip').hide();
        },
   };

    return service;
   }]);

In index.html index.html中

<div class="col-md-12 main-view" ng-controller="ccar14a.common.drillDownController">

<div class="ddt-container">
    <h2>
    <span>
        {{config.title}} v{{config.version}}.
        <a href="" ng-click="getInitialFilter(true)"
                    ng-disabled="aggService.gridDisconnected" ng-if="config.initialTitle">
            {{config.initialTitle}}</a>
        <!--<span class="pull-right" style="font-size: 10px">, RDA: {{config.rda}}</span>-->
        <!--<span class="pull-right" style="font-size: 10px">Bridge: {{config.bridge | bridgeDomain}}</span>-->
    </span>
    <div class="ddt-links pull-right">
        <a href="" ng-click="about()">
            About</a>
        <a href="" ng-click="help()">
            Help</a>
    </div>
</h2>
</div>

<!--div container for filter overlay starts here-->

<div class="container-fluid ddt-container" ng-controller="ccar14a.common.drillDownController" id="ccar14a">
    <h2 ng-hide="true" class="remove">
    <span>
        {{config.title}} v{{config.version}}.
        <a href="" ng-click="getInitialFilter(true)"
                    ng-disabled="aggService.gridDisconnected" ng-if="config.initialTitle">
            {{config.initialTitle}}</a>
        <!--<span class="pull-right" style="font-size: 10px">, RDA: {{config.rda}}</span>-->
        <!--<span class="pull-right" style="font-size: 10px">Bridge: {{config.bridge | bridgeDomain}}</span>-->
    </span>
    <div class="ddt-links pull-right">
        <a href="" ng-click="about()">
            About</a>
        <a href="" ng-click="help()">
            Help</a>
    </div>
</h2>


    <div class="ddt-sidebar filter-overlay col-md-2">

        <div class="row">
            <div class="col-md-6">
                <div class="form-group ddt-filter-box-group">
                    <select class="form-control ddt-filter-box-fld" ng-model="savedFilter" ng-change="aggService.submitScenario(filter)">
                        <option value="">My Saved Filters</option>
                    </select>
                </div>
            </div>

            <div class="col-md-6">
                <button type="button" class="filter-close close-filter pull-right" ng-click="aggService.openFilterOverlay()"><i class="glyphicon glyphicon-remove filter-close"></i></button>

            </div>
        </div>

        <!--The code continues having several filter box  -->
 <div class="ddt-content col-xs-12" ng-class="{'col-md-10': !showControlPanel, 'col-xs-12' : !showControlPanel}">
            <div class="ddt-grid" ng-controller="ccar14a.common.AggController" ng-show="config.displaySummaryGrid">
                <ng-include src="'templates/summaryGrid.html' | embedUrl"></ng-include>
</div>

In summaryGrid.html summaryGrid.html中

<div class="grid-header">

<button type="button" class="btn btn-sm ddt-btn-medium pull-left" ng-show="true" ng-click="aggService.openFilterOverlay();">
    <i class="glyphicon glyphicon-filter" tooltip="Open Filter" tooltip-placement="right"></i>
</button>
<!-- Code for other functionalities continues-->
</div>

In styles.css styles.css中

.filter-overlay {
position: absolute;
left: -500px;
background: #EEE;
transition: 1s;
z-index: 1000;
box-shadow: 5px 5px 10px 3px #aaaaaa;
height: 100%;
min-width:365px;
overflow-y: auto;
 }

.filter-overlay.open {
transition: 1s;
left: 0;
}

.filter-overlay .row {
margin-left: 0;
margin-right: 0;
margin-top: 8px;
margin-botton: 12px;}

.container-fluid {
background-color: #F0F3F6;
height: 100%;
padding: 18px;}

.container-fluid .row{
margin-left: 0;
margin-right: 0;}

.ddt-content {
padding-left: 0;
padding-right: 0;
background-color: white;}

.tab-content > .tab-pane {
display: none;}

.tab-content > .active {
display: block;}

If you disable the parent element then obviously the children elements will also be disabled. 如果禁用父元素,那么显然子元素也将被禁用。 Instead of making them parent and children you can place those two divs as siblings and hide them individually depending on the visibility of the element. 您可以将这两个div放置为兄弟姐妹,并根据元素的可见性单独隐藏它们,而不是将它们作为父级和子级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当孩子活跃时将父div更改为活跃 - Change parent div to active when child is active 如何在父div中使用Jquery而不影响子div的情况下淡入和淡出背景图像? - How can I fade are background image in and out using Jquery in a parent div without having it affect the child div? 悬停父级时如何向子级 div 添加样式? - How can I add a style to a child div when hovering the parent? 当我单击子 div 时如何关闭父 div 函数,当我再次单击父 div 时,该函数将活动 - How can I close parent div function when I clicked child div and when I clicked parent div again, the function will activity 当我单击父 div 时如何切换子 div - How to toggle a child div when i click on a parent div 当父 Div 悬停时更改子 Div 的背景颜色 - Change Background-Color of Child Div When Parent Div is Hovered 单击父容器div时可以切换IMG src吗? - Can I switch IMG src when clicking the parent container div? 如何缩放 SVG 以适应父 div 容器? - How can I scale an SVG to fit the parent div container? 如何在现有父级和子级之间插入 DIV *之间? - How can I insert a DIV *between* an existing parent and child? 当我们只有孩子的ID时,如何使用js更改父div的宽度和高度 - How can I change the width and height of parent div using js when we only have the id of the child
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM