Create an alternative wait in javascript
Read your framework's documentation

Before you actually do some voodoo magic on your code, I suggest you read your framework's documentation. It's quite impossible that a web framework has not taken into account JS's asynchronous nature. There should be a proper way to do this.

For instance, in Meteor we have the .rendered handler which runs when the template has rendered or rerendered. This is usually where we hook stuff or modify the DOM to the newly rendered template.

Mutation observers

This is one of the new, shiny toys of JS and should be the proper way to do this operation in plain JS. Mutation Observers listen for changes on the DOM and fire assigned callbacks. You can configure them to listen for specific changes on the DOM, like attribute modifications, subtree modifications (adding or removing DOM). As of this writing, current browsers support them already.

Using AJAX? The callbacks!

When there is AJAX, there should be some mechanism to attach handlers to know when the data arrived. Use that instead.

For example, in jQuery you can do this:

$.get('some_resource_url')
 .done(function(data){
   //Do something with the data when it arrives
 });