ClickerMonkey / SemanticUI-Angular

Angular Directives for Semantic UI
http://clickermonkey.github.io/SemanticUI-Angular/examples/
MIT License
56 stars 28 forks source link

Fix element.ready() triggered early than tab menu item doms rendered … #16

Closed jinyangzhen closed 7 years ago

jinyangzhen commented 7 years ago

…when using sm-tab-menu in partial view

First thanks for building angular 1.x bindings for semantic ui.

It is not easy to reproduce this issue in small example as it is something to do with async rendering with complicated nested view. We found in our case element.ready() in sm-tab-menu is triggered early than the ready of ng-repeat population for sm-tab-menu DOM. The initialization to tab menu is failed because the below line returns empty list.

var elements = element.children('.item');

I fixed this by replacing element.ready() with $browser.notifyWhenNoOutstandingRequests(), this callback is triggered after all DOM population is finished

ClickerMonkey commented 7 years ago

Thanks for your contribution, the timing for initializating modules definitely needs to be worked on to ensure its completely stable.

What made you choose $browser.notifyWhenNoOutstandingRequests over $timeout ?

jinyangzhen commented 7 years ago

Hi Philip

Sorry for this late response.

AFAIK $timeout isn't reliable, though i tested it and it is working in my case too. I choose $browser.notifyWhenNoOutstandingRequests cos Angular testing framework Protactor is using it to determine all dynamic rendering is completed. and this can ensure all pending DOM population done before attaching semantic event handlers.

On Wed, Sep 21, 2016 at 8:45 AM, Philip Diffenderfer < notifications@github.com> wrote:

Thanks for your contribution, the timing for initializating modules definitely needs to be worked on to ensure its completely stable.

What made you choose $browser.notifyWhenNoOutstandingRequests over $timeout ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ClickerMonkey/SemanticUI-Angular/pull/16#issuecomment-248478809, or mute the thread https://github.com/notifications/unsubscribe-auth/ABsozk1t8NjD7uQXXViAmcP0wqhz0r8lks5qsH4vgaJpZM4KBuZj .