ForgeComponents
en

Components

j-SnackBar

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20
  • singleton
  • info message SETTER('snackbar/show', 'MESSAGE', '[BUTTON_LABEL]', [callback_dismiss])
  • success message SETTER('snackbar/success', 'MESSAGE', '[BUTTON_LABEL]', [callback_dismiss])
  • warning message SETTER('snackbar/warning', 'MESSAGE', '[BUTTON_LABEL]', [callback_dismiss])
  • NEW waiting message SETTER('snackbar/waiting', 'MESSAGE', '[BUTTON_LABEL]', [callback_dismiss])
  • message can contain HTML code

Configuration:

  • button {String} A label for dismiss button (default: OK)
  • timeout {Number} A timeout in milliseconds (default: 4000)

Works with ASETTER:

  • errors are handled automatically
// Without callback
AJAX('POST /api/profile/', userprofile, ASETTER('snackbar/response', 'Profile has been saved successfully'));

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

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

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

Use it with <ui-component name="snackbar">. 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.

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

<div style="position: absolute; bottom: 0; left: 10px;">
	<a href="https://totaljs.com" title="totaljs.com">Totaljs.com</a>
</div>
<div style="position: absolute; bottom: 0; right: 50px;">
	<a href="https://componentator.com" title="componentator.com">Componentator.com</a>
</div>

<script>
	SETTER(true, 'snackbar/success', 'This is a message!', function() {
		// Optional
		console.log('Dismiss');
	});
</script>