All Products
Search
Document Center

SuperApp:Action list

Last Updated:Oct 25, 2024

This topic describes the JavaScript API of WVUIActionSheet. You can refer to this topic when you create HTML5 apps or MiniApps. You can use the JavaScript API of WVUIActionSheet to display an action sheet.

WVUIActionSheet.show

Displays an action sheet (a list of buttons displayed at the bottom of the sheet).

Effect on iOS devices

Effect on Android devices

image

WVUIActionSheet_show_Android@2x.png

Input parameters

  • [string]title: the title of the action sheet.

  • [int]index: the index of the action sheet. The index is used to uniquely identify an action sheet.

  • [array]buttons: the array of buttons that are displayed in the action sheet. Each item in the array is a string and indicates the title of the button.

    An action sheet always ends with an extra button: the Cancel button.

Callback parameters

No callback parameters exist. If the action sheet is displayed, the success callback is invoked. Otherwise, the failure callback is invoked.

Event listening

The wv.actionsheet event indicates that you respond to the action sheet.

Event parameters:

  • [string]type: the text of the button that you tap.

  • [int]_index: the index of the action sheet.

Important
  • If you tap the Cancel button or tap a position outside the action sheet UI on an iOS device, the event whose type is cancel is triggered.

  • If you tap the Cancel button on an Android device, an event that does not contain the type property is triggered. If you tap a position outside the action sheet UI on an Android device, no event is triggered.

document.addEventListener('wv.actionsheet', function(e) {
        alert(JSON.stringify(e.param));
}, false);

var params = {
        // The title of the action sheet.
        title: 'Choose a button!',
        // The index of the action sheet.
        _index: 32768,
        // The buttons that are displayed in the action sheet.
        buttons: ['Button 1', 'Button 2', 'Button 3', 'Button 4', 'Button 5']
};
window.WindVane.call('WVUIActionSheet', 'show', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});