minddust / bootstrap-progressbar

progressbar interactions for twitter bootstrap 2 & 3
www.minddust.com/project/bootstrap-progressbar
MIT License
577 stars 160 forks source link

Callback function "done" fires immediately #47

Closed talena6 closed 9 years ago

talena6 commented 9 years ago

Hi, I'm not good with js/jquery, can you please let me know why this isn't working? It removes/replaces the class before the progress bar loads.

I have this at the bottom of my html file, before the closing body tag, after bootstrap-progressbar.js:

<script>
    $(document).ready(function() {
        $('.progress .progress-bar').progressbar({
          done: $('.loading').removeClass('loading').addClass('loaded')
        });
    });
</script>
ghost commented 9 years ago

That's simple: you should pass closure.

When you pass

done: $('.loading').removeClass('loading').addClass('loaded')

It's instantly evaluated. Instead try passing

done: function() { $('.loading').removeClass('loading').addClass('loaded') }

It's a closure that will be evaluated only after done really fires.

minddust commented 9 years ago

@ptihiy yep. thanks for replying :)