Hi,
I have a small behavior that prevents doubleclick on buttons.
It is added to Modal popups on a page. The problem i have is that if the
Modal window appears twice on a page,
the javascript variable value of the first popup is used.
This is because i am using: response.renderJavascript(...); which is only
rendered once.
How can i force rerendering of the javascript, or is there any other way of
achieving defaulting the javascript variable,
for each modal window on my page?
This is how it my behavior looks:
public class PreventDoubleClickBehavior extends AbstractBehavior {
private String submitScript = "if(submitting) {this.disabled = true;
return false;} else {submitting = true;}";
@Override
public void renderHead(IHeaderResponse response) {
response.renderJavascript("var submitting = false;", "pdcJS");
}
@Override
public void onComponentTag(Component component, ComponentTag tag) {
IValueMap valueMap = tag.getAttributes();
CharSequence oldOnclickFunctions =
valueMap.getCharSequence("onclick");
if (oldOnclickFunctions == null) {
oldOnclickFunctions = "";
}
tag.put("onclick", submitScript + oldOnclickFunctions);
}
}
Thanks in advance...
Muro