message

AbstractItem.message(mess, options)
Domain:

client

Language:

javascript

Class:

AbstractItem()

Description

Use message method to create a modal form.

Parameters

Parameter

Type

Description

mess

string

Specifies the text or HTML content that will appear in the body of the form.

options

object

Is an object with the following attributes:

Attribute

Type

Description

title

string

The title of the form.

Default: empty

width

integer

The width of the form.

Default: 400px

height

integer

The height of the form.

Default: empty

margin

string

Defines the margins of the form body.

Default: empty

text_center

boolean

If true, the body tags will be centered.

Default: false

buttons

object

An object defining the buttons created in the footer of the form.

Keys are button names, values are functions executed when the corresponding button is clicked.

Default:

button_min_width

integer

The minimum width of the buttons.

Default: 100px

center_buttons

boolean

If true, the buttons will be centered.

Default: false

close_button

boolean

If true, a close button is created in the upper-right corner of the form.

Default: true

close_on_escape

boolean

If true, the form is closed when the user presses Escape.

Default: true

print

boolean

If true, a print button is created in the upper-right corner of the form to print its body.

Default: false

The buttons Object

The buttons attribute defines the buttons displayed in the footer of the form.

It is a plain object where each key/value pair describes one button.

Key

Value type

Description

Yes

function

Functions executed when the button is clicked

No

function

Functions executed when the button is clicked

Cancel

function

Functions executed when the button is clicked

Example

var buttons = {
        Yes: yesCallback,
        No: noCallback,
        Cancel: cancelCallback
    };

Return

The method returns a jquery object of the form. To programmatically close the form pass this object to the hide_message method.

Examples

The following code will create a yes-no-cancel dialog:

function yes_no_cancel(item, mess, yesCallback, noCallback, cancelCallback) {
    var buttons = {
        Yes: yesCallback,
        No: noCallback,
        Cancel: cancelCallback
    };
    item.message(mess, {buttons: buttons, margin: "20px",
        text_center: true, width: 500, center_buttons: true});
}
task.message(
    '<a href="http://jam-py.com/" target="_blank"><h3>Jam.py</h3></a>' +
    '<h3>Demo application</h3>' +
    ' with <a href="http://chinookdatabase.codeplex.com/" target="_blank">Chinook Database</a>' +
    '<p>by Andrew Yushev</p>' +
    '<p>2015</p>',
    {title: 'Jam.py framework', margin: 0, text_center: true,
        buttons: {"Yes": undefined, "No": undefined, "Cancel": undefined},
        center_buttons: true}
);

The result of the code above will be:

Message method example