You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Marco Di Sabatino Di Diodoro <ma...@tirasa.net> on 2012/11/21 15:29:37 UTC

Close ModalWindow with key press

Hi, 

I like close my modalwindow with key press event. 
Before 6.3.0 I used the following code

    private static final String PRE_JS = "$(document).ready(function() {\n"
            + "$(document).bind('keyup', function(evt) {\n"
            + "    if (evt.keyCode == 27){\n";

    private static final String POST_JS = "\n evt.preventDefault();\n"
            + "evt.stopPropagation();\n"
            + "    }\n"
            + "  });\n"
            + "});";

    @Override
    protected void respond(final AjaxRequestTarget target) {
        modalWindow.close(target);
    }

but it not works with firefox. 
After new release, I create a class that extends AjaxEventBehavior:

    @Override
    protected void onEvent(AjaxRequestTarget target) {
        modalWindow.close(target);
    }

    @Override
    protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
        super.updateAjaxAttributes(attributes);
        attributes.setChannel(new AjaxChannel("modalClose", Type.ACTIVE));
    }

In this case, I have some problem to set focus on my modalwindow (with firefox). 
How can I manually set focus on my modalwindow?

I used target.focusComponent(editModalWin) without success.

Regards
Marco

Dott. Marco Di Sabatino Di Diodoro
Tel. +39 3939065570

Tirasa S.r.l.
Viale D'Annunzio 267 - 65127 Pescara
Tel +39 0859116307 / FAX +39 0859111173
http://www.tirasa.net

Apache Syncope PPMC Member
http://people.apache.org/~mdisabatino





Re: Close ModalWindow with key press

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

To be able to focus a div you need to add 'tabindex' attribute to it.


On Wed, Nov 21, 2012 at 4:29 PM, Marco Di Sabatino Di Diodoro <
marco.disabatino@tirasa.net> wrote:

> Hi,
>
> I like close my modalwindow with key press event.
> Before 6.3.0 I used the following code
>
>     private static final String PRE_JS = "$(document).ready(function() {\n"
>             + "$(document).bind('keyup', function(evt) {\n"
>             + "    if (evt.keyCode == 27){\n";
>
>     private static final String POST_JS = "\n evt.preventDefault();\n"
>             + "evt.stopPropagation();\n"
>             + "    }\n"
>             + "  });\n"
>             + "});";
>
>     @Override
>     protected void respond(final AjaxRequestTarget target) {
>         modalWindow.close(target);
>     }
>
> but it not works with firefox.
> After new release, I create a class that extends AjaxEventBehavior:
>
>     @Override
>     protected void onEvent(AjaxRequestTarget target) {
>         modalWindow.close(target);
>     }
>
>     @Override
>     protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
>         super.updateAjaxAttributes(attributes);
>         attributes.setChannel(new AjaxChannel("modalClose", Type.ACTIVE));
>     }
>
> In this case, I have some problem to set focus on my modalwindow (with
> firefox).
> How can I manually set focus on my modalwindow?
>
> I used target.focusComponent(editModalWin) without success.
>
> Regards
> Marco
>
> Dott. Marco Di Sabatino Di Diodoro
> Tel. +39 3939065570
>
> Tirasa S.r.l.
> Viale D'Annunzio 267 - 65127 Pescara
> Tel +39 0859116307 / FAX +39 0859111173
> http://www.tirasa.net
>
> Apache Syncope PPMC Member
> http://people.apache.org/~mdisabatino
>
>
>
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>