# j-Message

> j-Message: singleton; easy usage

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: a793e95708c8086f7287312baec181c47ca6d2fbd28c52615e86da59ef044d11
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- singleton
__Configuration__:

- `button {String}` a button label (default: `OK`)
- `style {Number}` can change a style (default: `1`), style `2` is similiar to `j-Approve` component
- `closeoutside {Boolean}` enables closing of message box by clicking outside of main button

__Usage__:

```js
SETTER('message/warning', 'Some warning');
SETTER('message/success', 'Some success message');
SETTER('message/info', 'Some info message');
```

__Works with ASETTER__:

- errors are handled automatically

```js
// Without callback
AJAX('POST /api/profile/', userprofile, ASETTER('message/response', 'Profile has been saved successfully'));

// Or with a callback
AJAX('POST /api/profile/', userprofile, ASETTER('message/response', 'Profile has been saved successfully', function(response) {
	console.log(response);
}));

// Or with a callback and without message
AJAX('POST /api/profile/', userprofile, ASETTER('message/response', function(response) {
	console.log(response);
}));

// With auto-binding
AJAX('POST /api/profile/', userprofile, ASETTER('message/response', '?.response'));
AJAX('POST /api/profile/', userprofile, ASETTER('message/response', 'Your message', '?.response'));
```

Use it with `<ui-component name="message">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<ui-component name="message"></ui-component>

<script>
	setTimeout(function() {
		SETTER('message/success', 'Success message');
		// SETTER('message/warning', 'Warning message');
	}, 2000);
</script>
```
