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:
- $(function () {
- $('.imgGallery a').click(function (e) {
- e.preventDefault();
- previewImage($(this).attr('href'), $("img", this).attr('alt'));
- });
- $('.imgGallery').each(function (e) {
- $(this).hover(
- function() {
- $(this).css('border','2px solid #E49C16').css('cursor','pointer'); },
- function() {
- $(this).css('border','2px solid #F5F2EB');
- });
- });
- });
-
- function previewImage(uri, title) {
-
- //Get the HTML Elements
- imageDialog = $('#imgPopUp');
- imageTag = $('#image');
-
- //Set the image src
- imageTag.attr('src', uri);
-
- //When the image has loaded, display the dialog
- imageTag.load(function(){
-
- $('#imgPopUp').dialog({
- position: 'center',
- modal: false,
- resizable: false,
- draggable: true,
- width: 'auto',
- title: title
- });
- });
- }
I've put a basic, stripped down version here, to view the behavior:
Dialog Test
Any help on this is greatly appreciated! Thanks!
--Tor