wicket-jquery-ui
wicket-jquery-ui copied to clipboard
InputDialog - submit using enter key
Would be great if submit using entry could work with the InputDialog, any idea where to look to get this fixed?
Hi,
I think this can be handled (and activated trough a #isEnterEventEnabled
or something similar)
I will look at this...
Best regards, Sebastien.
Note for me:
$('#DialogTag').keypress(function(e) {
if (e.keyCode == $.ui.keyCode.ENTER) {
//Close dialog and/or submit here...
}
});
Hi actually, you can do it in wicket way :) no js something like that works for me (code in a class extending InputDialog):
this.getForm().add(new AjaxFormSubmitBehavior(this.getForm(), "submit")
{
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target)
{
super.onSubmit(target);
InputDialog.this.onSubmit(target);
for(DialogButton button : getButtons())
{
if(button.match(DialogButtons.OK.toString()))
{
InputDialog.this.onClick(target, button);
}
}
}
});
Hi,
That's another approach, well done! I will think further on this topic probably next week...
Thanks & best regards, Sebastien.
How well does this work with nested forms, as I can't seem to stop it submitting it. I return false in wantSubmitOnParentFormSubmit() for the nested form, and yet, it still executes a non-ajax submit on the nested form.
Hi,
I assume that's because the "submit" event is attached to AjaxFormSubmitBehavior
...
There is several ways to cancel to normal submit, but these should be tested in this specific case:
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
{
super.updateAjaxAttributes(attributes);
// do not allow normal form submit to happen
attributes.setPreventDefault(true);
}
@Override
public CharSequence getCallbackFunctionBody(CallbackParameter... parameters)
{
return super.getCallbackFunctionBody(parameters) + "return false;";
}
Best regards, Sebastien.