2

I generate "ui-bootstrap accordion" by ng-repeat. I want upddate value of list dynamically. But when I update nested list value, second accordion is not working.

    <uib-accordion close-others="oneAtATime">
        <uib-accordion-group heading="{{prInfo.name}}"
            data-ng-repeat="(a,prInfo) in allPersonInfoNames | filter:prSearchFilter">
            Below iss the inner accordion
            <uib-accordion close-others="oneAtATime">
                <uib-accordion-group heading="Static Payroll Header, inner accordion"
                    data-ng-repeat="(b,payroll) in prInfo.banks">
                    This content is straight in the template.
                </uib-accordion-group>
            </uib-accordion>

        </uib-accordion-group>
        <uib-accordion-group heading="{{group.title}}" ng-repeat="group in groups1">
            {{group.content}}
        </uib-accordion-group>
    </uib-accordion>

This code is work correctly, but when I generate list of banks after loading the html, accordion not working.

add ng-click="getBanks(prInfo)" to first accordion:

<uib-accordion-group heading="{{prInfo.name}}"
   data-ng-repeat="(a,prInfo) in allPersonInfoNames | filter:prSearchFilter"
   ng-click="getBanks(prInfo)">

$scope.getBanks = (personInfo) ->
        $scope.prResPromise = Cartable.httpReq('GET', "getBanks/#{personInfo.dbId}", null, (res) ->
          if res.isSuccess
            pi = _.findWhere($scope.allPersonInfoNames, {'dbId' : personInfo.dbId})
            index = $scope.allPersonInfoNames.indexOf(pi)
            $scope.allPersonInfoNames[index] = res

After this change, nested accordion is not working and first accordion doesn't open and second accordion doesn't generate.

If I set all accrodion to be open, both accordion work correctly, but when when I want open one of them, the problem accur again.

I do this with bootstrap accordion, but have this problem again.

3
  • 2
    Any plunker or jsfiddle to have a look at full code? Commented Dec 19, 2016 at 11:06
  • @YaserAdelMehraban I have try to add a plunker. Commented Dec 19, 2016 at 11:11
  • @YaserAdelMehraban When I try to add plunker, I found the problem. The problen is the version of `ui-bootstrap', I change version from 0.3 to 2.3.1 and the bug is fixed. Commented Dec 20, 2016 at 13:57

1 Answer 1

2

I solved the problem by 2 step,

first update the version of ui-bootstrap from 0.3 to 2.3.1, and then add specifice is-open to each of accordion.

            <uib-accordion close-others="oneAtATime1">
                <div uib-accordion-group class="panel-default" is-open="prInfo.isOpen" heading="{{prInfo.name}}"
                     ng-repeat="prInfo in allPersonInfoNames">
                    <uib-accordion close-others="oneAtATime2">
                        <div uib-accordion-group class="panel-default" heading="{{payroll.logPeriod.name}}"
                             is-open="payroll.isOpen"
                             ng-repeat="payroll in prInfo.payrolls">
                            <div class="row">
                                <div class="col-md-4">
                                    <h1>in nested accordion</h1>
                                </div>
                            </div>
                        </div>
                    </uib-accordion>
                </div>
            </uib-accordion>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.