SkyeBoniwell
SkyeBoniwell

Reputation: 7102

jquery ui dialog box: remove or close?

what is best practice when it comes to closing a jQuery UI dialog box? I use a dialog box so the user can perform a search.

When the user is finished, should I use .close() or .remove()?

My concern is, what if they decide to perform another search...would it be better to haved closed or removed the old one?

Thanks!

Upvotes: 0

Views: 38

Answers (1)

Scott Mermelstein
Scott Mermelstein

Reputation: 15397

Closing and showing is much faster than removing and recreating, but if it matters to you, any previous user input will still be in the dialog if you simply save it and show it.

In my experience, the best thing to do is keep the dialog around, and initialize it before (re-)opening it. This way, you keep adding or removing from the DOM to a minimum, and the initialize step gives you a chance to make sure the user sees what they're expecting to see.

Upvotes: 1

Related Questions