3.5.4Asking for a text value

You can ask the user for a text value using AskForText(). Note: this function only gives you a final result. You don't get an initial creation message from the dialog which gives you the ability to destroy it.

The simple usage is equivalent to the browser modalprompt(). You supply a string, and the user has the opportunity to change it. For example:

Framework.AskForText("Current value", function (result) {

// Text entered by user, or null if the user cancelled.

});

Instead of simply supplying the pre-populated value for the text field, you can supply a full dialog definition in which you can set a title plus standard dialog options such as noCancel. For example:

Framework.AskForText({

title: "Please enter your name",

heading: "What are you called?",

needValue: true, // User must enter a value, or else Save is disabled

text: "", // Text to prepopulate with

}, function (result) {

// Text entered by user, or null if the dialog is cancelled

});

In addition to standard dialog options, the full set of properties which you can provide is as follows:

Property

Description

title

Title for the dialog

heading

Optional heading to display above the text field

needValue

If true, the Save button is disabled unless the user enters a value. Note: if you set needValue but not the standard noCancel, then the user cannot click the Save button without entering a value, but can cancel the dialog.