Listen for changes in internet connectivity
In our Backbone.js app for Close.io I wanted to show a red bar when your internet connection is gone.
// Listen for changes in internet connectivity
(function() {
var errorView = null;
$(window).on('online', function() {
if (errorView) errorView.remove();
errorView = null;
});
$(window).on('offline', function() {
errorView = new ErrorView({ message: 'No internet connection.'});
errorView.render();
});
}());
Written by Phil Freo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Internet
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#