Skip to content

Dexie.on.versionchange

David Fahlander edited this page Mar 27, 2014 · 12 revisions

Syntax

db.on("versionchange", function (event) {});

Description

The "versionchange" event occurs if another indexedDB database instance with a newer version of the database needs to upgrade the database. If you do not subscribe to this event, Dexie has a built-in default implementation that will close the database immediately and reload the current web page. This will resume the upgrading process of the other page and the current page will be refreshed to get the latest version.

To override the default behavior, your subscriber function must return false.

Sample

var db = new Dexie("MyDB");
db.on("versionchange", function(event) {
    if (!confirm ("Another page tries to upgrade the database to version " + event.newVersion +
                  ". Accept?")) {
        return false;
    }
};
Clone this wiki locally