Search code examples
javascriptjquerysapui5keydownsap-fiori

SAPUI5 Handle Enter in Dialog


I'm implementing custom SAPUI5 application containing simple Dialog with two inputs and one dropdown list. As default values are saved by (begin)button from Dialog, but the requirement is to save all data using ENTER key.

I've implemented afterOpen event for dialog with following code:

onAfterDialogOpen: function (oEvent) {
    var oDialog = this;

    jQuery("input").on("keydown", function (oKeyEvent) {
        if (oKeyEvent.keyCode == 13) { // ENTER
            oKeyEvent.preventDefault();
            debugger
        }
    });
}

and it is triggered correctly, problem is that I don't know how to get all the values from dialog and call other functions from this controller.

Any idea? Some kind of proxy function? Thanks in advance


Solution

  • SAP has its own way of checking for enter. It's called onsapenter:

    oDialog.addEventDelegate({onsapenter: *functionyouwanttocall*}, this);
    

    More info can be found here.