From ac0571392b2e9ad2c82a4a41f132e594e4b67538 Mon Sep 17 00:00:00 2001 From: benweet Date: Sun, 14 Apr 2013 22:21:49 +0100 Subject: [PATCH] Add updateready event callback --- cache.manifest | 2 +- js/main.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cache.manifest b/cache.manifest index d42103f8..ea05272c 100644 --- a/cache.manifest +++ b/cache.manifest @@ -1 +1 @@ -CACHE MANIFEST # v36 CACHE: index.html css/bootstrap.css css/jgrowl.css css/main.css js/main-min.js js/require.js NETWORK: * +CACHE MANIFEST # v37 CACHE: index.html css/bootstrap.css css/jgrowl.css css/main.css js/main-min.js js/require.js NETWORK: * diff --git a/js/main.js b/js/main.js index 18e7e557..4b74098a 100644 --- a/js/main.js +++ b/js/main.js @@ -15,12 +15,14 @@ require(["jquery", "core"], function($, core) { $(function() { // If browser has detected a new application cache. - if (window.applicationCache - && window.applicationCache.status === window.applicationCache.UPDATEREADY) { - window.applicationCache.swapCache(); - window.location.reload(); - return; - } + if (window.applicationCache) { + window.applicationCache.addEventListener('updateready', function(e) { + if(window.applicationCache.status === window.applicationCache.UPDATEREADY) { + window.applicationCache.swapCache(); + window.location.reload(); + } + }, false); + } core.init(); });