Search code examples
jqueryfancyboxfancybox-3

jquery fancybox - append to current instance of fancybox


currently this is how I'm doing right now

$('.fancybox-inner').append(html);

suppose if there are two instances of fancybox opened, above code will append html to both instances of fancybox but I want to append it to current instance.

How can I achieve this ?

Any help is appreciated, Thanks.


Solution

  • Each instance contains variable $refs that is collection of references to DOM objects. So, you can change your snippet to:

    $.fancybox.getInstance().$refs.inner.append(html);
    

    btw, if you are executing this code from within callback, then you already have a reference to the instance (first argument)