A series of modal dialog api like toast
, alert
, confirm
and prompt
.
options
(object): some options.
message
(string): the message that the toast shows.
duration
(number): the duration(seconds) that the toast shows.
var modal = require('@weex-module/modal');
modal.toast({'message': 'I am toast!', 'duration': 1});
options
(object): some options.
message
(string): the message that the alert shows.
okTitle
(string): the title of alert button, default is OK.
callback
(function): callback when complete.
var arg1 = 'I am alert!'; var arg2 = 'I am ok'; var modal = require('@weex-module/modal'); modal.alert({ message: arg1, okTitle: arg2 }, function() { // TODO after the alert is complete. })
options
(object): some options.
message
(string): the message that the confirm shows.
okTitle
(string): the title of confirm button, default is 'OK'.
cancelTitle
(string): the title of cancel button, default is 'Cancel'.
callback
(function): callback when complete.
This method has a callback function whose arguments will be:
result
(string): the title of the button that clicked by user.
var arg1 = 'I am alert!' var arg2 = 'I am ok' var arg3 = 'I am cancel' var modal = require('@weex-module/modal'); modal.confirm({ message: arg1, okTitle: arg2, cancelTitle: arg3 }, function(result) { nativeLog(result) // TODO after the confirm is complete. });
options
(object): some options.
message
(string): the message that the prompt shows.
okTitle
(string): the title of confirm button, default is 'OK'.
cancelTitle
(string): the title of cancel button, default is 'Cancel'.
callback
(function): callback when complete.
This method has a callback function whose arguments will be:
res
(object): the argument will be a object, which has attributes result
and data
, like { result: 'OK', data: 'hello world' }
result
(string): the title of the button that clicked by user.
data
(string): the value of the text that entered by user.
var arg1 = 'I am prompt!' var arg2 = 'I am ok' var arg3 = 'I am cancel' var modal = require('@weex-module/modal'); modal.prompt({ message: arg1, okTitle: arg2, cancelTitle: arg3 }, function(res) { nativeLog(res.result + ', ' + res.data); // TODO after the prompt is complete. });