1

Is it possible to bind/setup/init featherlight without also opening the modal?

Currently var modal = $.featherlight($target,config) binds and then opens.

I have worked around it for now by immediately invoking modal.close() but this feels hacky.

Possible options:

1) New config option openOnBind (true/false)

2) Bind should not open by default - user can choose to use .open() afterwards as needed.

I have also tried var modal = $target.featherlight(config) but both $target.open() and modal.open() then fail - neither contain the featherlight object/instance.

Where is the featherlight instance hiding? :)

Fiddled: http://jsfiddle.net/eybb104r/2/

P.S. The context for this is launching a modal based on the presence of a cookie, so I need to bind a modal without a DOM element trigger.

iamkeir
  • 3,222
  • 2
  • 21
  • 22

1 Answers1

1

It's really unclear why you want to do this, as there aren't any useful methods to call on a closed featherlight.

It's not documented (nor really supported), but you can do:

var fl = new $.Featherlight($content, config);
// Do something here, really unclear what though
fl.open();
Marc-André Lafortune
  • 78,216
  • 16
  • 166
  • 166
  • Thanks - the context is that the modal is being launched depending on the presence of a certain browser cookie. – iamkeir Sep 21 '17 at 15:48
  • Is there a more logical way you would see Featherlight achieving this? Example context: http://jsfiddle.net/me12Ltaj/3/ – iamkeir Sep 21 '17 at 15:59
  • 1
    http://jsfiddle.net/yun8ospq/ or create yourself a function that calls featherlight, and call that function within your `if` – Marc-André Lafortune Sep 21 '17 at 23:21