Backbone.js progress bar while fetching collection

前端 未结 6 651
既然无缘
既然无缘 2021-02-09 10:43

i\'d like to show a progress bar while i update the app with fresh content. I guess the best thing to do would be to do it while calling .fetch on a collection.

The cont

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-09 11:10

    You could use jQuery ajaxStart and ajaxStop to show the progress on start and hide it on end. Doing it this way, however, will show your indicator any time and ajax request is made on your page.

    A route you could take if you want to limit it to just that particular fetch would be to override the sync method in that collection or model and wrap the default sync with some code that shows and hides the progress bar.

提交回复
热议问题