[v2] do dynamic dialogs need to be cleaned up? [solved]

Simple question, do dialogs created in this way need to be cleaned up with dialog.destroy()?

f7.dialog.create({ title: ‘title’, text: ‘text’ }).open();

Many of my dialogs are created when they are used so I want to avoid wasting memory. Thanks!

If you are not going to reuse it then yes, better to destroy it when it is closed

Thank you! For anyone else, adding the following to the dialog.create parameters seems to work. Calling destroy in the closed or onClick event will throw errors. An option to self destruct would be nice. :slight_smile:

on: {
    dialogClosed: function(dialog) {
1 Like

Sorry, just one more question. What should I do with dialogs like alert, confirm, and prompt? The docs and examples use them as one-time dialogs (f7.dialog.alert(‘text’,‘title’)) but they need to be cleaned up in the same way as dialog.create, correct? Perhaps a self destruct parameter for these one-time dialogs would be helpful?

Also, if you try to reuse an alert popup, it’s missing a click handler so the user cannot close it.

I’ll add this feature in next release


v2.0.7 changelog

New app.destroyPredefinedDialogs parameter to automatically destroy predefined dialogs like Alert, Confirm, Prompt, etc.

Thanks, alerts are now cleaned up on close by default. For anyone that would like this functionality for dialog.create, use the following parameter { destroyOnClose: true } in create. I wasn’t able to set it globally in the app instance: dialog.destroyPredefinedDialogs or destroyOnClose true but maybe I screwed up.