D
D
Dmitry Sch2019-06-06 14:13:17
JavaScript
Dmitry Sch, 2019-06-06 14:13:17

FancyBox 3 how to access content?

In an event

beforeShow: function(instance, current) {
  console.info('done!');
  console.info(current);
}

console outputs
{
  $content:[div.htmlDataBlock.fancybox, prevObject: k.fn.init(1)]
  $slide: [div.fancybox.fancybox, prevObject: k.fn.init(1)]
  $thumb: null
  contentType: "html"
  forcedDuration: undefined
  index: 0
  isComplete: true
  isLoaded: true
  isLoading: false
 }

but when called
beforeShow: function(instance, current) {
  console.info(current.$content);
}

returns undefined, what is the correct way to refer to the content of the slide? what are these properties written via $
Sandbox problem example

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Gribanov, 2019-06-06
@gribanov2la

For some reason, at the time of the console.log call, the $content property does not yet have an array of references to dom elements, they are filled later (but console.log shows the state not at the time of the call, but the actual one).
If you place the working code in the sandbox, you can understand what the problem is.

A
Alfieros, 2019-06-06
@mrsexy

Do you have the content part in html wrapped in ? <div class="fancybox"> контент для fancybox </div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question