Skip to content

Dexie.on.versionchange

David Fahlander edited this page Apr 6, 2016 · 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 fire a VersionChangeError error event to db.on('error'). This will resume the upgrading process of the other page.

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