On Fri, Feb 24, 2012 at 8:28 PM, DuneBug <[email protected]> wrote:
> I have a modal window with links, the links need to open a page in a new
> browser window, and close the modal window in the current window.
>
> This works fine with an ajaxLink with this onClick function EXCEPT THAT, it
> triggers browser pop-up blocking.
>
> @Override
>        public void onClick(AjaxRequestTarget target) {
>            String js = "window.open('" + url + "')";

Use window.open(url, "_blank"). See
http://www.w3schools.com/jsref/met_win_open.asp
_blank will tell the browser to open it in new window/tab

>            target.appendJavascript(js);
>            modalWindow.close(target);
>
>        }
>
> If there's a way to do this without triggering pop-up blocking that's good
> enough for me.
>
> OTHERWISE... In non-wicket I'd attach an onClick event to the href tag that
> would simply call some javascript to hide the window... I believe the
> approach to doing this in Wicket is to switch my links to ExternalLinks and
> add a behavior to them...
>
> i tried the following...
>
>    private static class CloseBehavior extends AbstractDefaultAjaxBehavior {
>
>        private static final long serialVersionUID = 1L;
>        private final ModalWindow modal;
>
>        public CloseBehavior( ModalWindow modal)
>        {
>            this.modal = modal;
>        }
>
>        @Override
>        protected void respond(AjaxRequestTarget target) {
>            modal.close(target);
>        }
>
>        @Override
>        public void renderHead( IHeaderResponse response) {
>
>            response.renderJavascript("" +
>                "$(document).ready(function() {\n" +
>                "  $(document).bind('click', function(evt) {\n" +
>                getCallbackScript() + "\n" +
>                "});", modal.getContentId());
>        }
>
>    }
>
> ExternalLink link1 = new ExternalLink("linky");
> link1.add( new CloseBehavior(modalWindow));
>
> ----
>
> Tried to do some searching but I think the problem is in the javascript in
> my behavior. I do have jquery available. Thanks for the help!
>
> Michael DeLauter
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/ExternalLink-close-modalWindow-tp4418218p4418218.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to