Velocity.toast()
Overview
Display a toast message in the current web page. Only use Velocity.toast() when you need to display a message from within a nested script that does not have access to the view. In all other circumstances use View.toast().
Generally, the default amount of time a toast message displays is 2 seconds, or if longDisplay is set to true, it displays for 3.5 seconds. The default length may vary depending on the version of the OS.
Added in 2.1.31
Only available in the Web View engine context. For more information, see Velocity Scripting APIs.
Format
Velocity.toast(message, longDisplay);
Parameter | Description | Type | Required |
---|---|---|---|
message | The message to display. | String | Required |
longDisplay | Set true if the message should be displayed for 3.5 seconds. | Boolean | Required |
Example
/* Display toast if an element with the id of field1 is not found.
*/
View.evaluateJavascript(
"if(!document.getElementById('field1')) {" +
" Velocity.toast('Field not found');" +
"}"
);