jQuery Is there a way to wait for object to load before continuing?
<p>I have a problem relating to cookies.
I have a group of buttons that display a specific table related to the button pushed. I have it setup to assign cookie values and I'm trying to get it to remember what was last viewed so users don't have to reselect everything every time they close the page.</p>

<pre><code>if($.cookie('lastviewed') == "value") {
   $('#Button1').trigger('click');
   $('#Button2').trigger('click');
}
</code></pre>

<p>Button 1 Loads in Button 2, so the above doesn't work because its trying to trigger something that doesn't exist yet.</p>

<p>Is there a way to make it wait for it to load before continuing?</p>

<p>Edit: I am already using document.ready.
Clicking button 1 loads button 2 onto the page, I need it to wait for it to finish loading in button 2 before it tries to click it.</p>
