In a code that I am working on there is a normal(no ajax) checkbox to which I want to append the JavaScript onchange event to it like:
checkbox.add(new AttributeAppender("onchange", Model.of("func(this);"), ""));
There is also anAjaxEventBehavior("onclick") added to the checkbox.
The function that must be called by onchange event is called just once even I check and uncheck the checkbox multiple times. I am guessing this has to do with the ‘ajax’ ‘onclick’ event.
How to make the func(this) called whenever the checkbox checked or unchecked?
Thank you
May be you can call your
func(this);function as aAjaxEventBehavior. getPreconditionScript()orgetSuccessScript(), instead of adding andAttributeAppenderon theonchangeevent.Take a look at
http://wicket.apache.org/apidocs/1.5/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.html#getPreconditionScript()
Your
AjaxEventBehaviorwill look similar to this: