Within some JavaScript I have to get the current post content of Gutenberg. I am accessing this from jQuery (might be bad practice, however):
$(document).ready(function() {
const { select } = wp.data;
var currentPost = select("core/editor").getCurrentPost();
});
Within this construct the content of currentPost
is undefined
.
Within:
$(document).ready(function() {
setTimeout(function(){
const { select } = wp.data;
var currentPost = select("core/editor").getCurrentPost();
}, 3000);
});
currentPost
is populated with everything I need.
As setTimeout
is always a desperate solution I am asking you kindly for the correct callback/way to start a certain process as soon as Gutenberg is fully initialized?