title: JavaScript event for when image 'src' attribute is changed?
body: <p>I have a function <code>resizePreview()</code> that will resize an image in a jQuery dialog box if the image is too big.  This image can be changed by the user.  My code goes something like this:</p>
  
  <pre><code>$('#imagePreview').attr('src', newImageSrc);
  resizePreview();
  </code></pre>
  
  <p><code>resizePreview()</code> uses <code>$('#imagePreview').width()</code> and <code>.height()</code> to get the dimensions and resizes accordingly. The problem is that the new image isn't loaded by the time <code>resizePreview()</code> is called so the image is resized according to it's original dimensions, not according to the dimensions of the newly loaded image.</p>
  
  <p>If I put an <code>alert()</code> call in between the two lines of code it works (since the alert gives the browser enough time to load the new image). Apparently I should use an event? Is there an existing event, or is there a way I can make one, for when the image src has changed (sort of like an onChange event, but for that attribute) or for when the new image has completed loading?  Thanks for your time.</p>