如何禁用手风琴组*我打开它之后? [英] How can I disable an accordion-group *after* I open it?

查看:159
本文介绍了如何禁用手风琴组*我打开它之后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,因为我无法得到一个回答我的问题在这里:
<一href=\"http://stackoverflow.com/questions/30538657/how-can-i-open-one-accordion-group-when-i-click-to-close-another-accordion-group\">How我可以开立一个手风琴组,当我点击关闭另一个手风琴组 - ?也许这是不可能的。

So since I couldn't get an answer to my question here: How can I open one accordion-group when I click to close another accordion-group? - Maybe it is not possible?

我一直在努力工作,各地至少完成诸如此类的什么,我想做的事情。

I have been working on a work-around to at least accomplish sort of what I want to do.

下面是我的手风琴:

<button class="panel accBtn" ng-click="status.isFirstOpen = !status.isFirstOpen;runThat()">Buildings<span class="caret"></span></button>
        <accordion class="m3Details">
            <accordion-group is-open="status.isFirstOpen" is-disabled="status.isFirstDisabled">
              <accordion-heading><span class="noQuery">Building<span class="caret"></span></span></accordion-heading>

                <li ng-repeat="y in m3Info" class="{{y.linkclass}}" ng-if="!y.offsite" ><a href="{{y.link}}" ng-click="clickLinks(y.initialOut,y.initialIn,y.backIn,y.backOut,y.name)"><img src="{{y.icon}}" width="15px" height="15px">{{y.name}}</a></li>


            </accordion-group>

            <accordion-group>
              <accordion-heading><span ng-click="runThis()">Offsites<span class="caret"></span></span></accordion-heading>
              <li ng-repeat="y in m3Info" class="{{y.linkclass}}" ng-if="y.offsite"><a href="{{y.link}}" ng-click="clickLinks(y.initialOut,y.initialIn,y.backIn,y.backOut,y.name)"><img src="{{y.icon}}" width="15px" height="15px">{{y.name}}</a></li>

            </accordion-group>

        </accordion>

第一手风琴组开出禁用,这是不必要的,因为确实我也有标题文本无形反正与类 NOQUERY 。然后,当我点击海水处理,该组打开了一个关闭建筑之列。我非常希望建筑当我关闭海水处理再次打开,但因为这似乎并​​不容易可行的我已经解决了有一对夫妇 NG-点击提供不同的功能。

The first accordion group starts out disabled, which is unnecessary really since I also have the heading text invisible anyway with the class noQuery. Then, when I click "Offsites", that group opens which closes the "Buildings" list. Ideally I would like "Buildings" to open again when I close "Offsites" but since that doesn't seem easily doable I have settled for having a couple of ng-click provide different functionality.

    $scope.runThis = function(){
        $('.accBtn').css('display','block');
        $scope.status.isFirstDisabled;
    };

    $scope.runThat = function(){
        $('.accBtn').css('display','none');
    }

在海水处理点击出现建筑的文字,然后在建筑时,建筑点击消失。我还是想一组常开,所以我想禁用能够点击海水处理时,它是开放的,这样,当它出现时,用户只能点击建筑。

The "Buildings" text appears when "Offsites" is clicked, and then "Buildings" disappears when "Buildings" is clicked. I still want one group always open so I would like to disable being able to click "Offsites" when it is open, that way the user can only click "Buildings" when it appears.

不过,我将如何去编程禁用手风琴被点击的标题是什么时候?或者,也许它会在一些有约束力的方式进行?

But how would I go about programmatically disabling the accordion when the heading is clicked? Or maybe it would be done in some binding way?

推荐答案

首先,采用了棱角分明的时候从jQuery的走就走!你的问题是只角肯定可以解决的。

First, stay away from jquery when using angular! Your problem is definitely solvable with just angular.

第二,我假设你正在使用的用户界面,引导,因为你正在使用的手风琴指令?

Second, I'm assuming you're using ui-bootstrap since you're using the accordion directive?

如果我理解正确,你想只有一个组同时启动,所以你只能点击是不开放的,基本上切换组的组。我成立了一个简单的 plunker 做这个。你必须使用是禁用手风琴组属性指令和切换一些布尔与 NG-点击来做到这一点。

If I understand you correctly, you want to only have one group active at a time so you can only click on the group that is not open and basically toggle the groups. I set up a simple plunker that does this. You have to use the is-disabled attribute on the accordion-group directives and toggle some booleans with ng-click to do this.

这篇关于如何禁用手风琴组*我打开它之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆