leocaseiro / angular-chosen

AngularJS Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a AngularJS way
http://leocaseiro.github.io/angular-chosen/
MIT License
682 stars 248 forks source link

Fix #189: Select element "flickers" on first page load #207

Closed boeserwolf closed 8 years ago

leocaseiro commented 8 years ago

Hi @boeserwolf, thanks for updating the tests. I really appreciate that.

However, it seems no tests are really running. I've tried to fail them, switching from true to false and so on, but they still passing through.

I believe karma doesn't wait for the dom to run the tests. I did some research about that, and I'll need to move the tests for a service.

boeserwolf commented 8 years ago

Hi @leocaseiro, thanks for your reply. Sorry, my bad, I should really have tested that.

That's interesting:

First, I don't think you should use document.ready, because all angular code will execute when document ready as default.

After further research, it looks like there's no need for $document.ready() or $timeout(), because Angular won't initialize until the DOM was loaded:

jqLite(window.document).ready(function() {
    angularInit(window.document, bootstrap);
  });

})(window);

As far as I understand, we should be good with just calling element.chosen(). I've updated the pull request correspondingly. Are you solving another specific issue by postponing the statement with $timeout()?

Thanks!

leocaseiro commented 8 years ago

Hi @boeserwolf,

Thanks again.

Unfortunately, I had to add $timeout to solve the issue #176

I'll need to work on this on the weekend. I'd like to have a solution for both issues.

liorcode commented 8 years ago

Seems #213 solves it

leocaseiro commented 8 years ago

Closes in regards to #213 Thanks for all help guys!