Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following dialog box might have code structured as listed below:

 

A More Complete Example

Code Block
languagejs
linenumberstrue
// ds is a reference to the DialogService.
 
var dialogId = 'app-dialog',
    dialogOpts = {
        edge: 'right'
    };
 
function createConfirmationText(action, itemId) {
    var content = ds.createDiv();
    content.append('p').text(action + ' ' + itemId);
    return content;
}

function confirmAction(action) {
    var itemId = $scope.selId,
    spar = $scope.sortParams;

    function dOk() {
        $log.debug('Initiating', action, 'of', itemId);
        wss.sendEvent(appMgmtReq, {
            action: action,
            name: siditemId,
            sortCol: spar.sortCol,
            sortDir: spar.sortDir
        });
    }

    function dCancel() {
        $log.debug('Canceling', action, 'of', itemId);
    }

    ds.openDialog(dialogId, dialogOpts)
        .setTitle('Confirm Action')
        .addContent(createConfirmationText(action, itemId))
        .addButton('OK', dOk)
        .addButton('Cancel', dCancel);
}
 
// e.g. confirmAction('activate');
//      $scope.selId contains the ID of the selected item