JQuery Modal Dialog - Destroy or Close?

五迷三道 提交于 2019-12-05 05:16:24

To be honest, I'm not sure. However you could use a javascript profiler to measure the time it takes to execute either way.

Here is a link to a mini-guide for the javascript profiler in Google Chrome's developer tools http://code.google.com/chrome/devtools/docs/profiles.html

I'd suggest that the 2nd option would be slower, as I'm guessing the selectors in "data" would need to be evaluated and therefore making it slower.

However, this is going to depend on how many times the dialogue is going to be opened / closed. As I'm guessing destroying and recreating will be slow (well in the blink of an eye - but perhaps a little bit slower).

The first seems like a simpler implementation, so if performance doesn't seem to be an issue - perhaps just choose the simpler of the two.

It depends on how many elements you are using the function ClearDay. If the no of elements is large then the second approach ie. (Creating one dialog and reusing it) is good approach and vice-versa.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!