alexander-ruehle / paper-collapse

Collapsible paper cards.
http://bbo-code.com/components/paper-collapse
163 stars 60 forks source link

Not working in combination with AngularJS ng-repeat #3

Open mhartvig opened 9 years ago

mhartvig commented 9 years ago

Hi, I can’t get this working in combination with angularjs, the show/hide does not get trigged. My guess is that the event is not attached to the item’s since they are loaded async into the DOM and the event is only attached at page-load.

<md-item class="flex-item col-sm-9" ng-repeat="case in CaseCtrl.cases() | orderBy:'Modified':true | limitTo:1 | filter:CaseCtrl.searchText">
                <div class="collapse-card" data-ng-click="$.fn.paperCollapse">
                    <div class="title">
                        <i class="fa fa-question-circle fa-2x fa-fw"></i>
                        <span>01:40</span>
                        <strong>Well, hello there</strong>
                    </div>
                    <div class="body" style="display: none;">
                        Wall of text
                    </div>
                </div>
            </md-item>
            <div class="flex-item col-sm-9">
                <div class="collapse-card">
                    <div class="title">
                        <i class="fa fa-question-circle fa-2x fa-fw"></i>
                        <span>01:40</span>
                        <strong>Well, hello there</strong>
                    </div>
                    <div class="body" style="display: none;">
                        Wall of text
                    </div>
                </div>
            </div>

The first one does not work, the last works perfectly. I think this is the issue:

(function($) {
      $(function () {
      $('.collapse-card').paperCollapse({});
    });
  })(jQuery);
alexander-ruehle commented 8 years ago

I do not have much experience with angular. And i do not intend to include this soon. Your are free to provide this functionality if you like.

bchong95 commented 8 years ago

I found a stackoverflow explaining how you can get this to work with AngularJS.

http://stackoverflow.com/questions/29272873/how-to-rewrite-this-jquery-plugin-into-angularjs

Basically you can have an ng-click .toggleClass('active'). I hacked this in by giving each of my cards an id using ng-repeat's $index.