检票口复选框AttributeAppender [英] wicket checkbox AttributeAppender
问题描述
在一个code,我的工作就没有一个正常的(不阿贾克斯)复选框
来我要追加的JavaScript 的onchange
事件给它这样的:
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);"), ""));
还有一个 AjaxEventBehavior(onclick事件)
添加到复选框
。
这必须由的onchange
被称为事件被称为只有一次,即使我检查,并取消复选框
多重功能次。我猜测这有做的阿贾克斯的onclick事件。
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.
如何让 FUNC(本)
称为每当复选框
选中或取消?
How to make the func(this)
called whenever the checkbox
checked or unchecked?
感谢您
推荐答案
可能是你可以打电话给你的 FUNC(本);
函数作为 AjaxEventBehavior。 GET preconditionScript()
或 getSuccessScript()
和 AttributeAppender
中,而不是添加在的onchange
事件。
May be you can call your func(this);
function as a AjaxEventBehavior. getPreconditionScript()
or getSuccessScript()
, instead of adding and AttributeAppender
on the onchange
event.
看看 <一href="http://wicket.apache.org/apidocs/1.5/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.html#get$p$pconditionScript" rel="nofollow">http://wicket.apache.org/apidocs/1.5/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.html#get$p$pconditionScript()
您 AjaxEventBehavior
将类似于此:
new AjaxEventBehavior("onclick") {
protected void onEvent(AjaxRequestTarget target) {
System.out.println("ajax here!");
}
protected CharSequence getSuccessScript() {
return "func(this);";
}
}
这篇关于检票口复选框AttributeAppender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!