I think you could do it as follows. The js function 'bindYourEvent()' is
called after the the components that are added to the AjaxRequestTarget
are 're-painted'.
form.add(new AjaxButton("set") {
@Override
protected void onSubmit(final AjaxRequestTarget target,
final Form<?> form) {
target.appendJavascript("bindYourEvent();");
}
});
mfg Bernhard
Joseph Pachod schrieb:
hi
I've some components which require some client side javascript which
require one init call (for all) to be initialized. In fact, this init
call uses selectors to get at the components to work one.
My issues is with Ajax. It happens that, during it, some new
components required this init call are added.
As such, how could I trigger it only once per Ajax request ?
The pattern I'm targeting is for each component to initialize this way
to have a behavior in which something would be added only in Ajax
request cycle. For non ajax request cycle, I use jquery to do the
init, through:
$(document).ready(function(){
$.initEdit();
});
When trying to reach this goal, I tried to run the init call through
an header contributor, but the call is then done before my content is
put on the page, making it useless:
public abstract class AbstractEditBehavior extends AbstractBehavior
{
public AbstractEditBehavior(final AbstractTextComponent<?> component)
{
component.add(JQueryDependency.CORE);
component.add(new HeaderContributor(new IHeaderContributor()
{
public void renderHead(final IHeaderResponse response)
{
if ((AjaxRequestTarget.get() != null))
{
response.renderJavascript("jQuery.initEdit();", "ID"
+ response.hashCode());
}
}
}));
}
(...)
thanks in advance
best
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org