ForgeKomponenter
sv

Komponenter

j-SnackBar

jComponent 20 · jcomponent@20 component Exempel laddat med jComponent 20
  • singlar
  • Information om SETTER('snackbar/show', 'MESSAGE', '[BUTTON_LABEL]', [callback_dismiss])
  • Framgångsrik SETTER('snackbar/success', 'MESSAGE', '[BUTTON_LABEL]', [callback_dismiss])
  • Varning meddelande SETTER('snackbar/warning', 'MESSAGE', '[BUTTON_LABEL]', [callback_dismiss])
  • _NEW__ väntarmeddelande SETTER('snackbar/waiting', 'MESSAGE', '[BUTTON_LABEL]', [callback_dismiss])
  • message kan innehålla HTML kod

Konfigurera:

  • button {String} A etikett för avlägsnande knappen (default: OK)
  • timeout {Number} A timeout i millisekunder (default: 4000)

Arbetar med asetter:

  • Fel hanteras automatiskt
// 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'));

Använd den med <ui-component name="snackbar">När komponenten ännu inte är laddad, jComponent Ladda ner den första gången från adressen i DEF.fallback (en av Componentator Författare: Peter Širka. källa: The Componentator Komponenterna i lager, MIT licens.

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>