ForgeComponents
en

Components

j-Prompt

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

The component (singleton) displays a prompt window with single-line or multiline input.


Configuration:

  • zindex {Number} optional (default: 12)
  • width {Number} optional, max. width (default: 400)
  • cancel {String} optional, label for the cancel button (default: Cancel)
  • submit {String} optional, label for the submit button (default: OK)

Example:

var opt = {};
opt.name = 'A title'; // optional
opt.summary = 'A small sumarization'; // optional
opt.value = ''; // a default value, optional
// opt.type = 'password'; // only for single-line mode
// opt.width = config.width; // max. width, optional
// opt.zindex = config.zindex; // a custom zindex, optional
// opt.centered = true; // centers the window to the middle of the screen
// opt.newbie = true; // allows to submit a default value
// opt.multiline = true; // NEW: enables textarea with 3 rows
// opt.monospace = true; // NEW: enables monospace text

opt.cancel = function(val) {
	// @val {String}
	// prompt is canceled
};

opt.callback = function(val) {
	// @val {String}
	// changed
};

opt.hide = function() {
	// prompt is hidden/closed
};

SETTER('prompt/show', opt);

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

<script>
	setTimeout(function() {
		var opt = {};
		opt.name = 'Folder name';
		opt.summary = 'Enter a folder name for your documents:';
		opt.value = '';

		opt.callback = function(val) {
			console.log('Returned', val);
		};

		opt.cancel = function(val) {
			console.log('Canceled', val);
		};

		opt.hide = function() {
			console.log('Hidden');
		};

		SETTER('prompt/show', opt);
	}, 1000);
</script>