Skip to content

Build your personal knowledge base with Trilium Notes

handling of beforeunload - we save the note before unloading the page

azivneraf33a30ad897
diff --git a/static/js/init.js b/static/js/init.js
index 812c0d943f..d9821b90b4 100644
--- a/static/js/init.js
+++ b/static/js/init.js
@@ -231,4 +231,9 @@ $("#jumpToNoteForm").submit(function() {
}
return false;
+});
+
+$(window).on('beforeunload', function(){
+ // asynchronously send the request and don't wait for result
+ saveNoteIfChanged();
});
\ No newline at end of file
diff --git a/static/js/note.js b/static/js/note.js
index 19052f2c5c..70562d393e 100644
--- a/static/js/note.js
+++ b/static/js/note.js
@@ -212,5 +212,5 @@ function encryptNote() {
// To print or store the binary data, you may convert it to hex
let encryptedHex = aesjs.utils.hex.fromBytes(encryptedBytes);
- console.log("encrypted: " + encryptedBytes);
+ console.log("encrypted: " + encryptedHex);
}
\ No newline at end of file