JQuery callback after append?

JQuery doesn't support a callback for append Also, it's much more efficient to append the data at once, rather than calling append for each element. See the code below.

JQuery doesn't support a callback for .append. Also, it's much more efficient to append the data at once, rather than calling . Append for each element.

See the code below. Every element-to-append is added to a string. Once the string has finished, a marker is added, and the HTML is appended.

Then, a poller is activated, checking whether the marker element exist in the DOM. If it exists, the poller is cleared, the marker is removed, and the code executes. Update: .

Substr(1) is used when the ID is set, because the ID shouldn't be prefixed by #. Var toAppend = ''; var markerID = 'mark-end-of-append' + (new Date).getTime(); //Random for(var i=0; i'; } toAppend += ''; $('#body'). Append(toAppend); var poller = window.

SetInterval(function(){ var detected = document. GetElementById(markerID); if(detected){ //DOM is much more efficient window. ClearInterval(poller); $(detected).remove(); //Remove marker for(var i=0; iLength; i++){ var loader = site.

PageDatai; $(loader. LoadInTo). Load(loader.

Url + ' ' + loader. UrlSection); } } }, 100); //Check 10x per second.

Thanks for the reply. I do appreciate it. I try what you have suggested.

– mtwallet Oct 23 at 11:27 @mtwallet I have just added an extra line. I noticed that loader wasn't defined at the first loop any more. – Rob W Oct 23 at 11:30 Thanks Rob tried it and it works great.

Need some time to figure out exactly what's happening here. Once again thanks your your help! – mtwallet Oct 23 at 11:35.

If what you're after is avoiding code-replication, you may create the new division in a temporary variable: for( ... ) { var loader = ...; var newDiv = createDiv( {id:loader. LoadInto } ); $('#body'). Append( newDiv ); $(newDiv).

Load( loader. Url + ' ' + loader. UrlSection ); } Where the createDiv function may look like function createDiv( settings ) { document.

CreateElement('div'); $(div). Class("section"); $(div). Id(settings.Id); return div; }.

Thanks for the reply. I do appreciate it. I try what you have suggested.

– mtwallet Oct 23 at 11:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions