Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

backbone.js - how and when to show a spinner

Tags:

Is there any sort of hooks in backbone where I can easily say "whenever any of the collections is fetching data, show the spinner, hide it when they're done"?

I have a feeling it will be more complicated than that and require overwriting specific functions. When should I show the spinner? On fetch() or refresh() or something else?

like image 374
Matthew Avatar asked Apr 29 '11 12:04

Matthew


1 Answers

You can use jQuery ajaxStart and ajaxStop. Those will globally run when an ajax request is made, so fetch and save will cause those to run. Add your code to show the spinner in the start and hide it in the end.

like image 155
ryanmarc Avatar answered Sep 19 '22 07:09

ryanmarc