You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by sorinev <so...@gmail.com> on 2016/07/26 17:51:59 UTC
Link - open modal on left click, new tab/window on
right-click/context
I have an AjaxLink on my page.
and the modal side of it is:
And this works just fine. When I click the link, a wicket modal window opens
with the content of that modal being loaded from an external url.
However, a request has been made to change the functionality slightly. When
left clicking, the behavior should remain as is, but when right clicking on
the link and choosing open in a new tab or window, it should open a new
tab/window with that external url instead of popping up the modal. I've
googled around and haven't found a way to do this.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-open-modal-on-left-click-new-tab-window-on-right-click-context-tp4675216.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Link - open modal on left click, new tab/window on right-click/context
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
Please show us what you have done so we can tell you what is still missing.
Google for "JavaScript preventDefault" and "JavaScript left middle right
click" to find out more about how those work.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Wed, Jul 27, 2016 at 10:36 PM, sorinev <so...@gmail.com> wrote:
> Changing the href worked. But it opens the page on both a left click and a
> right click -> new tab. This may be related to the second part having no
> effect (stopping the propagation), which may in turn be related to the
> third
> part. Since I don't really know javascript, I'm not sure what needs to go
> there.
>
> --
> View this message in context: http://apache-wicket.1842946.
> n4.nabble.com/Link-open-modal-on-left-click-new-tab-window-
> on-right-click-context-tp4675216p4675227.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Link - open modal on left click, new tab/window on
right-click/context
Posted by sorinev <so...@gmail.com>.
Changing the href worked. But it opens the page on both a left click and a
right click -> new tab. This may be related to the second part having no
effect (stopping the propagation), which may in turn be related to the third
part. Since I don't really know javascript, I'm not sure what needs to go
there.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-open-modal-on-left-click-new-tab-window-on-right-click-context-tp4675216p4675227.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Link - open modal on left click, new tab/window on right-click/context
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
You can override onComponentTag() of this AjaxLink and do tag.put("href",
redirectUrl);
In addition you need to stop the propagation of the JS event: override
#updateAjaxAttributes() and do attributes.setEventPropagation(STOP)
One more thing you may need here is a precondition that checks whether it
is a left or right click. For this you can use:
attributes.getAjaxCallListeners().add(new
AjaxCallListener().onPrecondition("someJavaScriptThatUses attrs.event to do
the extra checks"))
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Tue, Jul 26, 2016 at 7:51 PM, sorinev <so...@gmail.com> wrote:
> I have an AjaxLink on my page.
>
>
>
> and the modal side of it is:
>
>
>
> And this works just fine. When I click the link, a wicket modal window
> opens
> with the content of that modal being loaded from an external url.
>
> However, a request has been made to change the functionality slightly. When
> left clicking, the behavior should remain as is, but when right clicking on
> the link and choosing open in a new tab or window, it should open a new
> tab/window with that external url instead of popping up the modal. I've
> googled around and haven't found a way to do this.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Link-open-modal-on-left-click-new-tab-window-on-right-click-context-tp4675216.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>