I can not access element (child) but it exists (fullCalendar)

0

Using the function eventAfterRender I am trying to access a child element that exists, however using the find() function, apparently is not finding . From the console, I can navigate to the child element as follows:

[0] (a.fc-time-grid-event.fc-v-event.fc-event.fc-start.fc-end.clicavel.rede)
 children
  [0] (div.fc-content)
   children
    [0] (div.fc-title)
     children
      [0] (img) <- esse é o elemento em questão

I tried the following ways, but without success:

$(element).find('img');
$(element).find('.fc-title').child().first();

Using the second try, I can get to the .fc-title element only, usually returning the element ( $(element).find('.fc-title') )

Remembering that the image element was added by the event title ( Events )

    
asked by anonymous 07.03.2018 / 18:39

1 answer

0

I came up with a bizarre solution and, as I realized, when I was trying to use find() , the element had not yet been rendered (I did not understand correctly), I used the setTimeout() function passing as time 0 ( I did not get it right) and apparently solved:

setTimeout(() => {
    $(element).find('img');
}, 0);
    
07.03.2018 / 19:03