0

I have attached the Plunker. I am unable to access .gc and .mc element . Although my code is working partially and class .bc is working as expected. I am trying to apply toggle effect on them and hierarchy wise

BroadCategory > GeneralCategory > MainCategory

Not sure what am I missing in

$(element).find('.gc').click( function() {
    alert('GC');
    $(element).find(".mc").slideToggle('200',function() {  
       $(element).find("span").toggleClass('faqPlus faqMinus');
    });
 });

2 Answers 2

1

When Angular links the BroadCategory div, the GeneralCategory (ng-repeat)elements have not yet been created yet. So the click handler is never added. Add the d-expand-collapse attribute to the .gc element. You should then see your click alert fire.

<div d-expand-collapse ng-repeat="gen in group.items">
Sign up to request clarification or add additional context in comments.

Comments

1

Your function is being called before the ng-repeat that creates the .gc elements. A quick fix would be to wrap the function in a timeout to let it finish rendering. I'm sure there is a better way using some hook in angular, but this will accomplish what you want.

setTimeout(function () {
  $(element).find('.gc').click( function() {
    alert('GC');
    $(element).find(".mc").slideToggle('200',function() {  
      $(element).find("span").toggleClass('faqPlus faqMinus');
    });
  });
});

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.