IE Dialog not firing the first time

IE Dialog not firing the first time

I'm having a strange issue with using the Dialog UI in IE.  I have click handlers set up for imgs on a page that utilize Dialog to display the full size image when they are clicked. So, I use a placeholder div at the bottom of the page that gets updated with the img src and then .dialog() is called on that div. 

Everything works fine in FF, Chrome, Safari, but in IE it seems that on the first click, the placeholder div updates, but no dialog.  Subsequent clicks fire the dialog, but then the title for the dialog, which is pulled from the img alt attribute is always one image behind (i.e. it displays the alt info from the last image clicked, not the current image).

This is the relevant javascript:

  1. $(function () {
  2. $('.imgGallery a').click(function (e) {
  3. e.preventDefault();
  4. previewImage($(this).attr('href'), $("img", this).attr('alt'));
  5. });
  6. $('.imgGallery').each(function (e) {
  7. $(this).hover( 
  8. function() {
  9. $(this).css('border','2px solid #E49C16').css('cursor','pointer'); },
  10. function() {
  11. $(this).css('border','2px solid #F5F2EB');  
  12. });
  13. });
  14. });
  15. function previewImage(uri, title) {
  16.  //Get the HTML Elements
  17.  imageDialog = $('#imgPopUp');
  18.  imageTag = $('#image');
  19.  
  20.  //Set the image src
  21.  imageTag.attr('src', uri);
  22.  
  23.  //When the image has loaded, display the dialog
  24.  imageTag.load(function(){
  25. $('#imgPopUp').dialog({
  26.  position: 'center',
  27.  modal: false,
  28.  resizable: false,
  29.  draggable: true,
  30.  width: 'auto',
  31.  title: title
  32. });
  33.  });   
  34. }
I've put a basic, stripped down version here, to view the behavior:  Dialog Test

Any help on this is greatly appreciated!  Thanks!

--Tor