You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Makundi <ma...@koodaripalvelut.com> on 2010/04/07 17:33:38 UTC
Select all options in a abstractchoice
This was so much fun ;)
public class SelectAllChoice extends CheckBox implements IHeaderContributor {
/**
* @param id
* @param abstractChoice
*/
public SelectAllChoice(String id, AbstractChoice<?, ?> abstractChoice) {
super(id);
add(WicketUtils.getAttribute("onchange", "if (this.checked) {
$('#" + abstractChoice.getMarkupId() + " *').attr('selected',
'selected'); } else { $('#" + abstractChoice.getMarkupId() + "
*').attr('selected', ''); $('#" + abstractChoice.getMarkupId() +
"').trigger('change'); } $('#" + abstractChoice.getMarkupId() +
"').trigger('change'); return false;"));
}
/**
* @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
*/
public void renderHead(IHeaderResponse response) {
response.renderJavascriptReference("/js/jquery.js");
}
}
**
Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org