You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kevin <Ke...@tvh.com> on 2016/02/15 09:50:13 UTC

AjaxEvent click and onclick

When i use a link (wicket 6.21.0 or 7.1.0) the java code below doesn't change
my element.
String js = "this.style.display = 'none';";
js += "document.getElementById('" + showLinkId + "').style.display = '';";
this.add(AttributeModifier.replace("click", js));

When is use the same code but use "onclick" instead of "click", everything
works fine.
I have been told that we should us "click" instead of "onclick". 
What am I doing wrong?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxEvent-click-and-onclick-tp4673590.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: AjaxEvent click and onclick

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

"click" should be used for Ajax behaviors because Wicket 6.0+ uses
JavaScript event listeners.
AttributeModifier modifies HTML attributes and they have to be prefixed
with "on".

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Feb 15, 2016 at 9:50 AM, Kevin <Ke...@tvh.com> wrote:

> When i use a link (wicket 6.21.0 or 7.1.0) the java code below doesn't
> change
> my element.
> String js = "this.style.display = 'none';";
> js += "document.getElementById('" + showLinkId + "').style.display = '';";
> this.add(AttributeModifier.replace("click", js));
>
> When is use the same code but use "onclick" instead of "click", everything
> works fine.
> I have been told that we should us "click" instead of "onclick".
> What am I doing wrong?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AjaxEvent-click-and-onclick-tp4673590.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
>
>