Assume I have the following function:
function createDiv(){
var div = $("<div>");
//here specify a callback to be triggered after the div has been attached to the DOM.
return div;
}
The div element will be attached to the DOM body, and assume I have no ideas on when it will really become part of the DOM. But eventually the other parts of the app will be responsible to attach the element to the active DOM. With this assumption in the createDiv function, I would like to have a callback to do the further processes that is only sensible after the element is in the DOM.
Is this type of callback achievable?