0

I recently posted a question concerning the possibility of different scroller div with the same class name. It works perfectly. Here is the link of the thread: Scroll multiple div at the same time

Lately, I've made ​​changes in my code to make all the div dynamic (with ng-repeat). Since these changes, my jquery function no longer works. I think the javascript is executed before my various ng-repeat is completed.

My function to scroll on all the container with the same class name :

var subCatContainer = $(".sub-category-container");
subCatContainer.scroll(function() {
    subCatContainer.scrollLeft($(this).scrollLeft());
});

Is there a solution in order to wait for my ng-repeat? in a directive?

To complete my explanation, I created a : JSFiddle

Community
  • 1
  • 1
Chéramy Alexandre
  • 444
  • 3
  • 8
  • 25
  • just wrap your jQuery that is floating in the air with a document ready – David Chase Apr 23 '14 at 13:47
  • I wrap my JQuery in my JSFiddle and it works. However it doesn't work my in my app. Do you know why? I have too much data? – Chéramy Alexandre Apr 23 '14 at 14:30
  • how is your data coming in? from a request? can you post an example? – David Chase Apr 23 '14 at 15:17
  • Yes from a request! i use `$http`. – Chéramy Alexandre Apr 23 '14 at 15:19
  • right so you are probably calling to the function before any data has populated into those divs therefore it does not work, you have to call the function after data has been populated... – David Chase Apr 23 '14 at 16:08
  • Yes, i'm agree with you. This is precisely the point of my question (it is certainly badly worded). How to call the function `scrollableContainer var = $ (" scrollable-container. ")` after data has been populated. Do you have any idea? – Chéramy Alexandre Apr 24 '14 at 07:29
  • if you are using `$http` then check this out https://code.angularjs.org/1.2.16/docs/api/ng/service/$http theres a success callback that you can use – David Chase Apr 24 '14 at 14:23
  • I created a directive that catch the last element of my `ng-repeat` and i update my var `subCatContainer = $(".sub-category-container");`. This post help me : [link](http://stackoverflow.com/questions/13471129/angularjs-ng-repeat-finish-event). Thank you for your help!!!! – Chéramy Alexandre Apr 25 '14 at 14:02

0 Answers0