Hi,
Thanks for the answer.
Here is a bit of my script :
[code]
// Constructing the modal...
SModule_gallery.oGalleryModal.jqm({modal: true})
.width((SModule_gallery.GALLERY_COLS *
(SModule_gallery.GALLERY_ITEM_WIDTH + 10)) + 4) // 6 et 4
correspondent à des paddings
.height(iHeight + 4 + 32) // 32 = height approximative
du title
.draggable({handle: 'h1'});
$(window).keydown(SModule_gallery.onKeyDown);
onKeyDown: function(oEvent)
{
if (oEvent.keyCode == 27)
SModule_gallery.hideGalleryModal();
},
hideGalleryModal: function()
{
SModule_gallery.oGalleryModal.jqmHide();
$(window).unbind('keydown', SModule_gallery.onKeyDown);
},
// Data inside the modal : looping over an ajax answer, displaying
several thumbnails
sStr += '<li id="galleryThumbnailItem_' + iId + '">\
<img
src="' + SDefines.sUrlAjax + 'getFilePreview.php?
fileId=' + iId + '&square=' + SModule_gallery.GALLERY_ITEM_WIDTH + '"
title="' + sName + '" />\
</li>';
[/code]
When I open the modal, and immediately press escape, this works fine :
the modal hides itself.
But when I first click on a picture (that displays some information in
the "main window"), and then press escape, I have to press escape
another time to hide the modal.
I could not succeed in catching the first escape event in an event
listener (either on $(window), or on the li item, or on the img
item....)
Thanks for any help ! :)
On 20 juil, 12:19, Liam Potter <[email protected]> wrote:
> show us you script and stop bumping so often.
>
> Lideln wrote:
> > Up !
>
> > On 17 juil, 22:47, Lideln <[email protected]> wrote:
>
> >> Up ! :)
>
> >> On 16 juil, 22:32, Lideln <[email protected]> wrote:
>
> >>> up
>
> >>> On 16 juil, 08:10, Lideln <[email protected]> wrote:
>
> >>>> up !
>
> >>>> (wow, this forum gets 10 new posts per hour....)
>
> >>>> On 15 juil, 21:52, Lideln <[email protected]> wrote:
>
> >>>>> Hi everybody !
>
> >>>>> I have a jqModal window, and I would like to close it using the ESC
> >>>>> key. For that purpose, I assign my modal a keydown() event, and if
> >>>>> keyCode == 27, I close the modal.
>
> >>>>> It works fine, except when I click on another element in the modal
> >>>>> first.... I have to press 2 times ESC : the first time removes the
> >>>>> focus from the element, the second time goes through my listener and
> >>>>> closes the modal.
>
> >>>>> In my modal , I have an ul/li list, each li containing an img (for the
> >>>>> purpose of an image gallery).
>
> >>>>> When I click on an image (or li ?), I have to press twice ESC to close
> >>>>> the modal. I tried to add a $(this).blur() in the li click() event,
> >>>>> and also I tried to put that in the img click event, but without
> >>>>> success...
>
> >>>>> Does somebody know why it is doing that, and how to fix it, please ?
>
> >>>>> Thanks a lot !