Featherlight:如何保存并重新访问 "persisted" 灯箱?

Featherlight: how to save and re-access "persisted" lightbox?

我使用 featherlight 的方式需要根据特定条件显示不同的灯箱。这意味着我一直在 JS 中调用它而不是使用数据属性。这是我正在尝试做的事情:

if ( filled.length == checked.length ) {
    $.featherlight('#enter-name', { 'persist' : true });
    $('#enter-name-name').trigger('focus');
    $('#enter-name-checked').html(filled.length);
} else {
    $.featherlight('#check-fields', { 'persist' : true });
}

这第一次效果很好;不幸的是,从 DOM.

中删除后,ID 将不再适用于 select 灯箱

有人告诉我,当使用 persist 选项时,灯箱内容实际上与 DOM 分离,而不是完全删除。如何将这个分离的元素保存为变量并重新打开它?

当前的行为将来可能会改变。同时,您应该将 return 存储在变量中。

var nameDialog = null;

if (...)
   if (!nameDialog) // First time...
     nameDialog = $.featherlight('#enter-name', { 'persist' : true });
   else // After that...
     nameDialog.open();
else
  ...