In modal dialogs
Suppose you have a dialog named "Dialog" with a button "BtnLogin" which we want to be the default button.
Set Dialog.JQDialogOptions.OnOpen.Script, preferentially using the design-time editor with the following code.
- Code: Select all
$(document).ready(function () {
$("input").on("keydown", function (event) {
var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
if (keycode == 13) {
$(<#BtnLogin#>).click();
return false;
} else {
return true;
}
});
});
In standard TIWAppForm:
Suppose you have a form named "FLogin" with a button "BtnLogin" which we want to be the default button.
In property FLogin.JavaScript add the above code.
In event FLogin.OnRender add:
- Code: Select all
procedure TFLogin.IWAppFormRender(Sender: TObject);
begin
JavaScript.Text := StringReplace(JavaScript.Text,'$(<#btnLogin#>)','document.getElementById('''+BtnLogin.JQHTMLName+''')',[rfReplaceAll,rfIgnoreCase]);
end;