d-before-unload
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -6,7 +6,4 @@ module.exports = BeforeUnload; | ||
BeforeUnload.prototype.create = function(model, dom) { | ||
// Don't do anything until the user makes some kind of mutation | ||
model.root.once('all', '**', function() { | ||
// Thereafter, stop the user from leaving the page whenever a change might be pending | ||
dom.on('beforeunload', window, listenerFn(model)); | ||
}); | ||
// Stop the user from leaving the page whenever a change might be pending | ||
dom.on('beforeunload', window, listenerFn(model)); | ||
}; | ||
@@ -16,3 +13,3 @@ | ||
return function beforeunloadListener(e) { | ||
if (!model.hasPending()) return; | ||
if (!model.hasWritePending()) return; | ||
var confirmationMessage = model.get('message') || | ||
@@ -19,0 +16,0 @@ 'You have unsaved changes. Do you want to leave this page and discard your changes?'; |
{ | ||
"name": "d-before-unload", | ||
"description": "Derby component to stop page from unloading when it has pending operations", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
1243
16