Closing tab with unsaved tiddlywiki - is there a better solution?

Folks,

As you know if your tiddlywiki has not being saved, or can’t be saved ,when you attempt to close the tab in the browser you get a prompt like this in firefox and other browsers;

Snag_a0716be

Now we can click to “stay on page” and save or even use a bookmarklet, to reset the dirty tag to stop this happening.

If you are trying to close a browser you have to restart the close browser each time, you hit one of these dialogues.

My Question is, is there a way for tiddlywiki to provide this dialogue instead of the browser and where we could code some alternative options? If this was possible we could provide options like;

  • Auto save and close
  • Save and continue
  • Reset dirty and continue
  • No discard and continue “Leave Page”
  • And “Stay on Page”

From other apps I have used it would seem this was possible however I have no idea where to start.

Have you developed a website or browser app that have dealt with this?, please share !

Examples please, so we could have a look.

The unsaved changes prompt is provided by the browser; TiddlyWiki gets to specify some of the text of the dialog, but has no further control over it.

It’s also worth noting that some browsers do not support the unsaved changes prompt, notably Safari on iOS and iPadOS.

1 Like

Also note that the text of the dialog can no longer be customized for most browsers, and last time I checked, the beforeunload() function used to trigger that prompt was being considered for deprecation alongside confirm(), alert() and prompt().

1 Like

Thanks all,

On revisiting some of the cloud solutions I have used, it seems the key way to deal with changes in tabs is for the app or site to always “autosave” so at close there is nothing left to save.

  • That is they avoid this browser prompt ever being tripped.

These tabs that do not trigger this message tend to be only when there is a “document list” which is used to access the document or tab in the first place, rather than relying on bookmarks or urls. With the document list being the primary way to access a document in a window or tab, and typically the document in the tab is retrieved from a database and uses autosave.

Perhaps in tiddlywiki a timed autosave that also saves temporary and draft tiddlers, between the autosaves that occur on “done” would be a solution to this? Once again by avoiding the message altogether.

What?! It will be a bleak and lonely world without alert.